diff options
Diffstat (limited to 'tools/editor')
75 files changed, 1748 insertions, 390 deletions
diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index 2f67df1fc3..a556031e5e 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -1933,12 +1933,20 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) { - v_scroll->set_val( v_scroll->get_val() - v_scroll->get_page() / 8 ); + if (mb.mod.command) { + zoom->set_val(zoom->get_val() + zoom->get_step()); + } else { + v_scroll->set_val( v_scroll->get_val() - v_scroll->get_page() / 8 ); + } } if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) { - v_scroll->set_val( v_scroll->get_val() + v_scroll->get_page() / 8 ); + if (mb.mod.command) { + zoom->set_val(zoom->get_val() - zoom->get_step()); + } else { + v_scroll->set_val( v_scroll->get_val() + v_scroll->get_page() / 8 ); + } } if (mb.button_index==BUTTON_RIGHT && mb.pressed) { diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 2779275ea8..9240e3527c 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -356,7 +356,7 @@ void FindReplaceBar::_show_search() { show(); search_text->grab_focus(); - if (text_edit->is_selection_active()) { + if (text_edit->is_selection_active() && !selection_only->is_pressed()) { search_text->set_text(text_edit->get_selection_text()); } @@ -376,12 +376,16 @@ void FindReplaceBar::popup_search() { void FindReplaceBar::popup_replace() { + if (!replace_hbc->is_visible() || !replace_options_hbc->is_visible()) { replace_text->clear(); replace_hbc->show(); replace_options_hbc->show(); + } + selection_only->set_pressed( (text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line()) ); + _show_search(); } @@ -409,6 +413,14 @@ void FindReplaceBar::_search_text_entered(const String& p_text) { search_next(); } +void FindReplaceBar::_replace_text_entered(const String& p_text) { + + if (selection_only->is_pressed() && text_edit->is_selection_active()) { + _replace_all(); + _hide_bar(); + } +} + String FindReplaceBar::get_search_text() const { return search_text->get_text(); @@ -452,6 +464,7 @@ void FindReplaceBar::_bind_methods() { ObjectTypeDB::bind_method("_editor_text_changed",&FindReplaceBar::_editor_text_changed); ObjectTypeDB::bind_method("_search_text_changed",&FindReplaceBar::_search_text_changed); ObjectTypeDB::bind_method("_search_text_entered",&FindReplaceBar::_search_text_entered); + ObjectTypeDB::bind_method("_replace_text_entered",&FindReplaceBar::_replace_text_entered); ObjectTypeDB::bind_method("_search_current",&FindReplaceBar::search_current); ObjectTypeDB::bind_method("_search_next",&FindReplaceBar::search_next); ObjectTypeDB::bind_method("_search_prev",&FindReplaceBar::search_prev); @@ -497,18 +510,19 @@ FindReplaceBar::FindReplaceBar() { replace_text = memnew(LineEdit); replace_hbc->add_child(replace_text); replace_text->set_custom_minimum_size(Size2(200, 0)); - replace_text->connect("text_entered",this,"_search_text_entered"); + replace_text->connect("text_entered",this,"_replace_text_entered"); + - replace = memnew(ToolButton); + replace = memnew(Button); replace_hbc->add_child(replace); replace->set_text(TTR("Replace")); - replace->set_focus_mode(FOCUS_NONE); + //replace->set_focus_mode(FOCUS_NONE); replace->connect("pressed",this,"_replace_pressed"); - replace_all = memnew(ToolButton); + replace_all = memnew(Button); replace_hbc->add_child(replace_all); replace_all->set_text(TTR("Replace All")); - replace_all->set_focus_mode(FOCUS_NONE); + //replace_all->set_focus_mode(FOCUS_NONE); replace_all->connect("pressed",this,"_replace_all_pressed"); Control *spacer_split = memnew( Control ); @@ -581,8 +595,10 @@ void FindReplaceDialog::popup_search() { void FindReplaceDialog::popup_replace() { + set_title(TTR("Replace")); bool do_selection=(text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line()); + set_replace_selection_only(do_selection); if (!do_selection && text_edit->is_selection_active()) { @@ -1112,8 +1128,10 @@ void CodeTextEditor::_update_font() { font_overridden = true; } } - if(!font_overridden) + if(!font_overridden) { + text_editor->add_font_override("font",get_font("source","EditorFonts")); + } } void CodeTextEditor::_on_settings_change() { @@ -1152,7 +1170,7 @@ void CodeTextEditor::_notification(int p_what) { _load_theme_settings(); emit_signal("load_theme_settings"); } - if (p_what==NOTIFICATION_ENTER_TREE) { + if (p_what==NOTIFICATION_THEME_CHANGED) { _update_font(); } } diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h index 2affa31482..6f59dda1ee 100644 --- a/tools/editor/code_editor.h +++ b/tools/editor/code_editor.h @@ -73,8 +73,8 @@ class FindReplaceBar : public HBoxContainer { TextureButton *hide_button; LineEdit *replace_text; - ToolButton *replace; - ToolButton *replace_all; + Button *replace; + Button *replace_all; CheckBox *selection_only; VBoxContainer *text_vbc; @@ -98,6 +98,7 @@ class FindReplaceBar : public HBoxContainer { void _search_options_changed(bool p_pressed); void _search_text_changed(const String& p_text); void _search_text_entered(const String& p_text); + void _replace_text_entered(const String& p_text); protected: void _notification(int p_what); diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index c4f2435675..1baad2c6b3 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -181,6 +181,14 @@ void ConnectDialog::ok_pressed() { error->popup_centered_minsize(); return; } + Node* target = tree->get_selected(); + if (target->get_script().is_null()) { + if (!target->has_method(dst_method->get_text())) { + error->set_text(TTR("Target method not found! Specify a valid method or attach a script to target Node.")); + error->popup_centered_minsize(); + return; + } + } emit_signal("connected"); hide(); diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index 5aac8bff09..320939cb97 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -42,11 +42,84 @@ void CreateDialog::popup(bool p_dontclear) { + recent->clear(); + + FileAccess *f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent."+base_type), FileAccess::READ ); + + if (f) { + + TreeItem *root = recent->create_item(); + + while(!f->eof_reached()) { + String l = f->get_line().strip_edges(); + + if (l!=String()) { + + TreeItem *ti = recent->create_item(root); + ti->set_text(0,l); + if (has_icon(l,"EditorIcons")) { + + ti->set_icon(0,get_icon(l,"EditorIcons")); + } else { + ti->set_icon(0,get_icon("Object","EditorIcons")); + } + } + } + + memdelete(f); + } + + favorites->clear(); + + f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites."+base_type), FileAccess::READ ); + + favorite_list.clear(); + + if (f) { + + + while(!f->eof_reached()) { + String l = f->get_line().strip_edges(); + + if (l!=String()) { + favorite_list.push_back(l); + } + } + + memdelete(f); + } else { +#if 0 +// I think this was way too confusing + if (base_type=="Node") { + //harcode some favorites :D + favorite_list.push_back("Panel"); + favorite_list.push_back("Button"); + favorite_list.push_back("Label"); + favorite_list.push_back("LineEdit"); + favorite_list.push_back("Node2D"); + favorite_list.push_back("Sprite"); + favorite_list.push_back("Camera2D"); + favorite_list.push_back("Area2D"); + favorite_list.push_back("CollisionShape2D"); + favorite_list.push_back("Spatial"); + favorite_list.push_back("Camera"); + favorite_list.push_back("Area"); + favorite_list.push_back("CollisionShape"); + favorite_list.push_back("TestCube"); + favorite_list.push_back("AnimationPlayer"); + + } +#endif + } + + _update_favorite_list(); + popup_centered_ratio(); if (p_dontclear) search_box->select_all(); - else + else { search_box->clear(); + } search_box->grab_focus(); _update_search(); @@ -104,7 +177,7 @@ void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_ty item->set_selectable(0,false); } else { - if (!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) { + if ((!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) || search_box->get_text()==p_type) { *to_select=item; } @@ -140,6 +213,8 @@ void CreateDialog::_update_search() { search_options->clear(); + favorite->set_disabled(true); + help_bit->set_text(""); /* TreeItem *root = search_options->create_item(); @@ -225,7 +300,7 @@ void CreateDialog::_update_search() { } - if (!to_select) { + if (!to_select || ct[i].name==search_box->get_text()) { to_select=item; } @@ -234,8 +309,11 @@ void CreateDialog::_update_search() { } } - if (to_select) + if (to_select) { to_select->select(0); + favorite->set_disabled(false); + favorite->set_pressed(favorite_list.find(to_select->get_text(0))!=-1); + } get_ok()->set_disabled(root->get_children()==NULL); @@ -246,6 +324,32 @@ void CreateDialog::_confirmed() { TreeItem *ti = search_options->get_selected(); if (!ti) return; + + FileAccess *f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent."+base_type), FileAccess::WRITE ); + + if (f) { + f->store_line(get_selected_type()); + TreeItem *t = recent->get_root(); + if (t) + t=t->get_children(); + int count=0; + while(t) { + if (t->get_text(0)!=get_selected_type()) { + + f->store_line(t->get_text(0)); + } + + if (count>32) { + //limit it to 32 entries.. + break; + } + t=t->get_next(); + count++; + } + + memdelete(f); + } + emit_signal("create"); hide(); } @@ -255,6 +359,7 @@ void CreateDialog::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { connect("confirmed",this,"_confirmed"); + favorite->set_icon(get_icon("Favorites","EditorIcons")); } if (p_what==NOTIFICATION_EXIT_TREE) { @@ -344,6 +449,9 @@ void CreateDialog::_item_selected() { String name = item->get_text(0); + favorite->set_disabled(false); + favorite->set_pressed(favorite_list.find(name)!=-1); + if (!EditorHelp::get_doc_data()->class_list.has(name)) return; @@ -351,12 +459,182 @@ void CreateDialog::_item_selected() { } + +void CreateDialog::_favorite_toggled() { + + TreeItem *item = search_options->get_selected(); + if (!item) + return; + + String name = item->get_text(0); + + if (favorite_list.find(name)==-1) { + favorite_list.push_back(name); + favorite->set_pressed(true); + } else { + favorite_list.erase(name); + favorite->set_pressed(false); + } + + _save_favorite_list(); + _update_favorite_list(); +} + +void CreateDialog::_save_favorite_list() { + + FileAccess *f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites."+base_type), FileAccess::WRITE ); + + if (f) { + + for(int i=0;i<favorite_list.size();i++) { + + f->store_line(favorite_list[i]); + } + memdelete(f); + } +} + +void CreateDialog::_update_favorite_list() { + + favorites->clear(); + TreeItem *root = favorites->create_item(); + for(int i=0;i<favorite_list.size();i++) { + TreeItem *ti = favorites->create_item(root); + String l = favorite_list[i]; + ti->set_text(0,l); + + if (has_icon(l,"EditorIcons")) { + + ti->set_icon(0,get_icon(l,"EditorIcons")); + } else { + ti->set_icon(0,get_icon("Object","EditorIcons")); + } + } +} + + +void CreateDialog::_history_selected() { + + TreeItem *item = recent->get_selected(); + if (!item) + return; + + search_box->set_text(item->get_text(0)); + _update_search(); + +} + +void CreateDialog::_favorite_selected(){ + + TreeItem *item = favorites->get_selected(); + if (!item) + return; + + search_box->set_text(item->get_text(0)); + _update_search(); + +} + +void CreateDialog::_history_activated() { + + _confirmed(); +} + +void CreateDialog::_favorite_activated(){ + + _confirmed(); +} + +Variant CreateDialog::get_drag_data_fw(const Point2& p_point,Control* p_from) { + + TreeItem *ti = favorites->get_item_at_pos(p_point); + if (ti) { + Dictionary d; + d["type"]="create_favorite_drag"; + d["class"]=ti->get_text(0); + + ToolButton *tb = memnew( ToolButton ); + tb->set_icon(ti->get_icon(0)); + tb->set_text(ti->get_text(0)); + set_drag_preview(tb); + + return d; + } + + return Variant(); +} + +bool CreateDialog::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{ + + Dictionary d = p_data; + if (d.has("type") && String(d["type"])=="create_favorite_drag") { + favorites->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN); + return true; + } + + return false; +} +void CreateDialog::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){ + + Dictionary d = p_data; + + TreeItem *ti = favorites->get_item_at_pos(p_point); + if (!ti) + return; + + String drop_at = ti->get_text(0); + int ds = favorites->get_drop_section_at_pos(p_point); + + int drop_idx = favorite_list.find(drop_at); + if (drop_idx<0) + return; + + String type = d["class"]; + + int from_idx = favorite_list.find(type); + if (from_idx<0) + return; + + if (drop_idx==from_idx) { + ds=-1; //cause it will be gone + } else if (drop_idx>from_idx) { + drop_idx--; + } + + favorite_list.remove(from_idx); + + if (ds<0) { + favorite_list.insert(drop_idx,type); + } else { + if (drop_idx>=favorite_list.size()-1) { + favorite_list.push_back(type); + } else { + favorite_list.insert(drop_idx+1,type); + } + } + + _save_favorite_list(); + _update_favorite_list(); + + +} + void CreateDialog::_bind_methods() { ObjectTypeDB::bind_method(_MD("_text_changed"),&CreateDialog::_text_changed); ObjectTypeDB::bind_method(_MD("_confirmed"),&CreateDialog::_confirmed); ObjectTypeDB::bind_method(_MD("_sbox_input"),&CreateDialog::_sbox_input); ObjectTypeDB::bind_method(_MD("_item_selected"),&CreateDialog::_item_selected); + ObjectTypeDB::bind_method(_MD("_favorite_toggled"),&CreateDialog::_favorite_toggled); + ObjectTypeDB::bind_method(_MD("_history_selected"),&CreateDialog::_history_selected); + ObjectTypeDB::bind_method(_MD("_favorite_selected"),&CreateDialog::_favorite_selected); + ObjectTypeDB::bind_method(_MD("_history_activated"),&CreateDialog::_history_activated); + ObjectTypeDB::bind_method(_MD("_favorite_activated"),&CreateDialog::_favorite_activated); + + + ObjectTypeDB::bind_method("get_drag_data_fw",&CreateDialog::get_drag_data_fw); + ObjectTypeDB::bind_method("can_drop_data_fw",&CreateDialog::can_drop_data_fw); + ObjectTypeDB::bind_method("drop_data_fw",&CreateDialog::drop_data_fw); ADD_SIGNAL(MethodInfo("create")); @@ -365,12 +643,44 @@ void CreateDialog::_bind_methods() { CreateDialog::CreateDialog() { + HSplitContainer *hbc = memnew( HSplitContainer ); + + add_child(hbc); + set_child_rect(hbc); + + VBoxContainer *lvbc = memnew( VBoxContainer); + hbc->add_child(lvbc); + lvbc->set_custom_minimum_size(Size2(150,0)*EDSCALE); + + favorites = memnew (Tree ); + lvbc->add_margin_child(TTR("Favorites:"),favorites,true); + favorites->set_hide_root(true); + favorites->set_hide_folding(true); + favorites->connect("cell_selected",this,"_favorite_selected"); + favorites->connect("item_activated",this,"_favorite_activated"); + favorites->set_drag_forwarding(this); + + + recent = memnew (Tree ); + lvbc->add_margin_child(TTR("Recent:"),recent,true); + recent->set_hide_root(true); + recent->set_hide_folding(true); + recent->connect("cell_selected",this,"_history_selected"); + recent->connect("item_activated",this,"_history_activated"); + VBoxContainer *vbc = memnew( VBoxContainer ); - add_child(vbc); - set_child_rect(vbc); + hbc->add_child(vbc); + vbc->set_h_size_flags(SIZE_EXPAND_FILL); + HBoxContainer *search_hb = memnew( HBoxContainer ); search_box = memnew( LineEdit ); - vbc->add_margin_child(TTR("Search:"),search_box); + search_box->set_h_size_flags(SIZE_EXPAND_FILL); + search_hb->add_child(search_box); + favorite = memnew( Button ); + favorite->set_toggle_mode(true); + search_hb->add_child(favorite); + favorite->connect("pressed",this,"_favorite_toggled"); + vbc->add_margin_child(TTR("Search:"),search_hb); search_box->connect("text_changed",this,"_text_changed"); search_box->connect("input_event",this,"_sbox_input"); search_options = memnew( Tree ); diff --git a/tools/editor/create_dialog.h b/tools/editor/create_dialog.h index 41156b538a..706a06ae16 100644 --- a/tools/editor/create_dialog.h +++ b/tools/editor/create_dialog.h @@ -32,6 +32,7 @@ #include "scene/gui/dialogs.h" #include "scene/gui/button.h" #include "scene/gui/tree.h" +#include "scene/gui/item_list.h" #include "scene/gui/line_edit.h" #include "scene/gui/label.h" #include "editor_help.h" @@ -46,6 +47,12 @@ class CreateDialog : public ConfirmationDialog { OBJ_TYPE(CreateDialog,ConfirmationDialog ) + + Vector<String> favorite_list; + Tree *favorites; + Tree *recent; + + Button *favorite; LineEdit *search_box; Tree *search_options; String base_type; @@ -55,6 +62,15 @@ class CreateDialog : public ConfirmationDialog { void _item_selected(); void _update_search(); + void _update_favorite_list(); + void _save_favorite_list(); + void _favorite_toggled(); + + void _history_selected(); + void _favorite_selected(); + + void _history_activated(); + void _favorite_activated(); void _sbox_input(const InputEvent& p_ie); @@ -63,6 +79,9 @@ class CreateDialog : public ConfirmationDialog { void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root,TreeItem **to_select); + Variant get_drag_data_fw(const Point2& p_point,Control* p_from); + bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const; + void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from); protected: diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index 35ec1ebfcc..8fc18b5b39 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -877,8 +877,7 @@ bool EditorSelection::is_selected(Node * p_node) const { return selection.has(p_node); } - -Array EditorSelection::_get_selected_nodes() { +Array EditorSelection::_get_transformable_selected_nodes() { Array ret; @@ -890,6 +889,18 @@ Array EditorSelection::_get_selected_nodes() { return ret; } +Array EditorSelection::_get_selected_nodes() { + + Array ret; + + for (Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) { + + ret.push_back(E->key()); + } + + return ret; +} + void EditorSelection::_bind_methods() { ObjectTypeDB::bind_method(_MD("_node_removed"),&EditorSelection::_node_removed); @@ -897,6 +908,7 @@ void EditorSelection::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_node","node:Node"),&EditorSelection::add_node); ObjectTypeDB::bind_method(_MD("remove_node","node:Node"),&EditorSelection::remove_node); ObjectTypeDB::bind_method(_MD("get_selected_nodes"),&EditorSelection::_get_selected_nodes); + ObjectTypeDB::bind_method(_MD("get_transformable_selected_nodes"),&EditorSelection::_get_transformable_selected_nodes); ADD_SIGNAL( MethodInfo("selection_changed") ); } diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h index a0b716f560..59f9d4e4f3 100644 --- a/tools/editor/editor_data.h +++ b/tools/editor/editor_data.h @@ -233,6 +233,8 @@ public: void _update_nl(); Array _get_selected_nodes(); + Array _get_transformable_selected_nodes(); + protected: static void _bind_methods(); diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp index f6ce7bf3f8..cf0732501e 100644 --- a/tools/editor/editor_dir_dialog.cpp +++ b/tools/editor/editor_dir_dialog.cpp @@ -143,7 +143,7 @@ void EditorDirDialog::set_current_path(const String& p_path) { reload(); String p = p_path; if (p.begins_with("res://")) - p.replace_first("res://",""); + p = p.replace_first("res://",""); Vector<String> dirs = p.split("/"); @@ -162,13 +162,13 @@ void EditorDirDialog::set_current_path(const String& p_path) { ERR_FAIL_COND(!p); String pp = p->get_metadata(0); if (pp=="") { + p->set_metadata(0,String(r->get_metadata(0)).plus_file(d)); _update_dir(p); - updating=true; - p->set_collapsed(false); - updating=false; - _item_collapsed(p); - } + updating=true; + p->set_collapsed(false); + updating=false; + _item_collapsed(p); r=p; } @@ -216,7 +216,7 @@ void EditorDirDialog::_make_dir_confirm() { if (err!=OK) { mkdirerr->popup_centered_minsize(Size2(250,80)); } else { - reload(); + set_current_path(dir.plus_file(makedirname->get_text())); } makedirname->set_text(""); // reset label } diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index 582b9e2490..be1af16576 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -208,10 +208,14 @@ void EditorFileSystemDirectory::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_file_count"),&EditorFileSystemDirectory::get_file_count); ObjectTypeDB::bind_method(_MD("get_file","idx"),&EditorFileSystemDirectory::get_file); ObjectTypeDB::bind_method(_MD("get_file_path","idx"),&EditorFileSystemDirectory::get_file_path); - ObjectTypeDB::bind_method(_MD("get_file_types","idx"),&EditorFileSystemDirectory::get_file_type); + ObjectTypeDB::bind_method(_MD("get_file_type","idx"),&EditorFileSystemDirectory::get_file_type); ObjectTypeDB::bind_method(_MD("is_missing_sources","idx"),&EditorFileSystemDirectory::is_missing_sources); ObjectTypeDB::bind_method(_MD("get_name"),&EditorFileSystemDirectory::get_name); - ObjectTypeDB::bind_method(_MD("get_parent"),&EditorFileSystemDirectory::get_parent); + ObjectTypeDB::bind_method(_MD("get_path"),&EditorFileSystemDirectory::get_path); + ObjectTypeDB::bind_method(_MD("get_parent:EditorFileSystemDirectory"),&EditorFileSystemDirectory::get_parent); + ObjectTypeDB::bind_method(_MD("find_file_index","name"),&EditorFileSystemDirectory::find_file_index); + ObjectTypeDB::bind_method(_MD("find_dir_index","name"),&EditorFileSystemDirectory::find_dir_index); + } @@ -1341,6 +1345,16 @@ void EditorFileSystem::update_file(const String& p_file) { void EditorFileSystem::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("get_filesystem:EditorFileSystemDirectory"),&EditorFileSystem::get_filesystem); + ObjectTypeDB::bind_method(_MD("is_scanning"),&EditorFileSystem::is_scanning); + ObjectTypeDB::bind_method(_MD("get_scanning_progress"),&EditorFileSystem::get_scanning_progress); + ObjectTypeDB::bind_method(_MD("scan"),&EditorFileSystem::scan); + ObjectTypeDB::bind_method(_MD("scan_sources"),&EditorFileSystem::scan_sources); + ObjectTypeDB::bind_method(_MD("update_file","path"),&EditorFileSystem::update_file); + ObjectTypeDB::bind_method(_MD("get_path:EditorFileSystemDirectory","path"),&EditorFileSystem::get_path); + ObjectTypeDB::bind_method(_MD("get_file_type","path"),&EditorFileSystem::get_file_type); + ADD_SIGNAL( MethodInfo("filesystem_changed") ); ADD_SIGNAL( MethodInfo("sources_changed",PropertyInfo(Variant::BOOL,"exist")) ); diff --git a/tools/editor/editor_fonts.cpp b/tools/editor/editor_fonts.cpp index 47891eef6c..bcf41cbac8 100644 --- a/tools/editor/editor_fonts.cpp +++ b/tools/editor/editor_fonts.cpp @@ -158,17 +158,10 @@ void editor_register_fonts(Ref<Theme> p_theme) { p_theme->set_font("doc_source","EditorFonts",df_doc_code); - if (editor_is_hidpi()) { - //replace default theme - Ref<Texture> di; - Ref<StyleBox> ds; - fill_default_theme(p_theme,df,df_doc,di,ds,true); + //replace default theme + Ref<Texture> di; + Ref<StyleBox> ds; + fill_default_theme(p_theme,df,df_doc,di,ds,EDSCALE); - } else { - Ref<Texture> di; - Ref<StyleBox> ds; - fill_default_theme(p_theme,df,df_doc,di,ds,false); - - } } diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index 8f486ba0c2..4f83dc2f66 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -882,6 +882,15 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->pop(); } + if (cd.methods[i].qualifiers.find("vararg")!=-1) { + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color")); + class_desc->add_text(","); + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color")); + class_desc->add_text(" ... "); + class_desc->pop(); + class_desc->pop(); + } + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color")); class_desc->add_text(cd.methods[i].arguments.size()?" )":")"); class_desc->pop(); diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index 357d139c04..d90a175811 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -1441,7 +1441,7 @@ bool EditorExportPlatformPC::can_export(String *r_error) const { String err; bool valid=true; - if (use64 && (!exists_export_template(debug_binary64)) || !exists_export_template(release_binary64)) { + if (use64 && (!exists_export_template(debug_binary64) || !exists_export_template(release_binary64))) { valid=false; err="No 64 bits export templates found.\nDownload and install export templates.\n"; } diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp index 20613467d3..02af9712a8 100644 --- a/tools/editor/editor_log.cpp +++ b/tools/editor/editor_log.cpp @@ -161,7 +161,7 @@ void EditorLog::_undo_redo_cbk(void *p_self,const String& p_name) { void EditorLog::_bind_methods() { ObjectTypeDB::bind_method(_MD("_clear_request"),&EditorLog::_clear_request ); - + ObjectTypeDB::bind_method("_override_logger_styles",&EditorLog::_override_logger_styles ); //ObjectTypeDB::bind_method(_MD("_dragged"),&EditorLog::_dragged ); ADD_SIGNAL( MethodInfo("clear_request")); } @@ -193,11 +193,10 @@ EditorLog::EditorLog() { ec->set_custom_minimum_size(Size2(0,180)); ec->set_v_size_flags(SIZE_EXPAND_FILL); - - PanelContainer *pc = memnew( PanelContainer ); - pc->add_style_override("panel",get_stylebox("normal","TextEdit")); + pc = memnew( PanelContainer ); ec->add_child(pc); pc->set_area_as_parent_rect(); + pc->connect("enter_tree", this, "_override_logger_styles"); log = memnew( RichTextLabel ); log->set_scroll_follow(true); @@ -224,6 +223,11 @@ void EditorLog::deinit() { } +void EditorLog::_override_logger_styles() { + + pc->add_style_override("panel",get_stylebox("normal","TextEdit")); + +} EditorLog::~EditorLog() { diff --git a/tools/editor/editor_log.h b/tools/editor/editor_log.h index 699be710d8..bbf35b63cb 100644 --- a/tools/editor/editor_log.h +++ b/tools/editor/editor_log.h @@ -50,6 +50,7 @@ class EditorLog : public VBoxContainer { HBoxContainer *title_hb; // PaneDrag *pd; Control *ec; + PanelContainer *pc; static void _error_handler(void *p_self, const char*p_func, const char*p_file,int p_line, const char*p_error,const char*p_errorexp,ErrorHandlerType p_type); @@ -64,6 +65,7 @@ protected: static void _bind_methods(); void _notification(int p_what); + void _override_logger_styles(); public: void add_message(const String& p_msg, bool p_error=false); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index f4b67f6e2b..c17cf05ea7 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -176,17 +176,6 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) { if (p_event.type==InputEvent::KEY && p_event.key.pressed && !p_event.key.echo && !gui_base->get_viewport()->gui_has_modal_stack()) { - if (ED_IS_SHORTCUT("editor/fullscreen_mode", p_event)) { - if (distraction_free_mode) { - distraction_free_mode = false; - _update_top_menu_visibility(); - } else { - set_docks_visible(!get_docks_visible()); - } - } - if (ED_IS_SHORTCUT("editor/distraction_free_mode", p_event)) { - set_distraction_free_mode(!get_distraction_free_mode()); - } if (ED_IS_SHORTCUT("editor/next_tab", p_event)) { int next_tab = editor_data.get_edited_scene() + 1; next_tab %= editor_data.get_edited_scene_count(); @@ -277,10 +266,12 @@ void EditorNode::_notification(int p_what) { circle_step=0; circle_step_msec=tick; - circle_step_frame=frame+1; - - update_menu->set_icon(gui_base->get_icon("Progress"+itos(circle_step+1),"EditorIcons")); + circle_step_frame=frame+1; + // update the circle itself only when its enabled + if (!update_menu->get_popup()->is_item_checked(3)){ + update_menu->set_icon(gui_base->get_icon("Progress"+itos(circle_step+1),"EditorIcons")); + } } scene_root->set_size_override(true,Size2(Globals::get_singleton()->get("display/width"),Globals::get_singleton()->get("display/height"))); @@ -785,7 +776,7 @@ bool EditorNode::_find_and_save_resource(RES res,Map<RES,bool>& processed,int32_ if (changed || subchanged) { //save print_line("Also saving modified external resource: "+res->get_path()); - Error err = ResourceSaver::save(res->get_path(),res,flags); + ResourceSaver::save(res->get_path(),res,flags); } processed[res]=false; //because it's a file @@ -1228,7 +1219,8 @@ void EditorNode::_dialog_action(String p_file) { //_save_scene(p_file); _save_scene_with_preview(p_file); - _run(false); + _call_build(); + _run(true); } } break; @@ -1374,6 +1366,7 @@ void EditorNode::_dialog_action(String p_file) { unzClose(pkg); } break; + case RESOURCE_SAVE: case RESOURCE_SAVE_AS: { @@ -2646,6 +2639,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case RUN_PLAY: { _menu_option_confirm(RUN_STOP,true); + _call_build(); _run(false); } break; @@ -2681,17 +2675,19 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case RUN_PLAY_SCENE: { _menu_option_confirm(RUN_STOP,true); + _call_build(); _run(true); } break; case RUN_PLAY_NATIVE: { - + bool autosave = EDITOR_DEF("run/auto_save_before_running",true); if (autosave) { _menu_option_confirm(FILE_SAVE_ALL_SCENES, false); } if (run_native->is_deploy_debug_remote_enabled()){ _menu_option_confirm(RUN_STOP,true); + _call_build(); emit_signal("play_pressed"); editor_run.run_native_notify(); } @@ -2803,6 +2799,10 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { update_menu->get_popup()->set_item_checked(1,true); OS::get_singleton()->set_low_processor_usage_mode(true); } break; + case SETTINGS_UPDATE_SPINNER_HIDE: { + update_menu->set_icon(gui_base->get_icon("Collapse","EditorIcons")); + update_menu->get_popup()->toggle_item_checked(3); + } break; case SETTINGS_PREFERENCES: { settings_config_dialog->popup_edit_settings(); @@ -2817,6 +2817,12 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { file_templates->popup_centered_ratio(); } break; + case SETTINGS_TOGGLE_FULLSCREN: { + + OS::get_singleton()->set_window_fullscreen( !OS::get_singleton()->is_window_fullscreen() ); + + + } break; case SETTINGS_PICK_MAIN_SCENE: { @@ -3002,6 +3008,8 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) { singleton->main_editor_buttons.push_back(tb); singleton->main_editor_button_vb->add_child(tb); singleton->editor_table.push_back(p_editor); + + singleton->distraction_free->raise(); } singleton->editor_data.add_editor_plugin( p_editor ); singleton->add_child(p_editor); @@ -3014,7 +3022,11 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) { for(int i=0;i<singleton->main_editor_buttons.size();i++) { - if (p_editor->get_name()==singleton->main_editor_buttons[i]->get_name()) { + if (p_editor->get_name()==singleton->main_editor_buttons[i]->get_text()) { + + if (singleton->main_editor_buttons[i]->is_pressed()) { + singleton->_editor_select(EDITOR_SCRIPT); + } memdelete( singleton->main_editor_buttons[i] ); singleton->main_editor_buttons.remove(i); @@ -4044,6 +4056,7 @@ void EditorNode::_quick_opened() { void EditorNode::_quick_run() { + _call_build(); _run(false,quick_run->get_selected()); } @@ -4139,6 +4152,11 @@ void EditorNode::register_editor_types() { //ObjectTypeDB::register_type<EditorImportExport>(); ObjectTypeDB::register_type<EditorSettings>(); ObjectTypeDB::register_type<EditorSpatialGizmo>(); + ObjectTypeDB::register_type<EditorResourcePreview>(); + ObjectTypeDB::register_type<EditorResourcePreviewGenerator>(); + ObjectTypeDB::register_type<EditorFileSystem>(); + ObjectTypeDB::register_type<EditorFileSystemDirectory>(); + //ObjectTypeDB::register_type<EditorImporter>(); @@ -4602,7 +4620,10 @@ void EditorNode::_update_dock_slots_visibility() { } void EditorNode::_update_top_menu_visibility() { - if (distraction_free_mode) { + + return; // I think removing top menu is too much + /* + if (distraction_free->is_pressed()) { play_cc->hide(); menu_hb->hide(); scene_tabs->hide(); @@ -4610,7 +4631,7 @@ void EditorNode::_update_top_menu_visibility() { play_cc->show(); menu_hb->show(); scene_tabs->show(); - } + }*/ } void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section) { @@ -4986,8 +5007,14 @@ bool EditorNode::get_docks_visible() const { return docks_visible; } +void EditorNode::_toggle_distraction_free_mode() { + + set_distraction_free_mode( distraction_free->is_pressed() ); +} + void EditorNode::set_distraction_free_mode(bool p_enter) { - distraction_free_mode = p_enter; + + distraction_free->set_pressed(p_enter); if (p_enter) { if (docks_visible) { @@ -5000,7 +5027,7 @@ void EditorNode::set_distraction_free_mode(bool p_enter) { } bool EditorNode::get_distraction_free_mode() const { - return distraction_free_mode; + return distraction_free->is_pressed(); } void EditorNode::add_control_to_dock(DockSlot p_slot,Control* p_control) { @@ -5232,6 +5259,24 @@ void EditorNode::add_plugin_init_callback(EditorPluginInitializeCallback p_callb EditorPluginInitializeCallback EditorNode::plugin_init_callbacks[EditorNode::MAX_INIT_CALLBACKS]; +int EditorNode::build_callback_count=0; + +void EditorNode::add_build_callback(EditorBuildCallback p_callback) { + + ERR_FAIL_COND(build_callback_count==MAX_INIT_CALLBACKS); + + build_callbacks[build_callback_count++]=p_callback; +} + +EditorPluginInitializeCallback EditorNode::build_callbacks[EditorNode::MAX_BUILD_CALLBACKS]; + +void EditorNode::_call_build() { + + for(int i=0;i<build_callback_count;i++) { + build_callbacks[i](); + } +} + void EditorNode::_bind_methods() { @@ -5300,6 +5345,7 @@ void EditorNode::_bind_methods() { ObjectTypeDB::bind_method("_clear_search_box",&EditorNode::_clear_search_box); ObjectTypeDB::bind_method("_clear_undo_history",&EditorNode::_clear_undo_history); ObjectTypeDB::bind_method("_dropped_files",&EditorNode::_dropped_files); + ObjectTypeDB::bind_method("_toggle_distraction_free_mode",&EditorNode::_toggle_distraction_free_mode); @@ -5344,7 +5390,7 @@ EditorNode::EditorNode() { changing_scene=false; _initializing_addons=false; docks_visible = true; - distraction_free_mode=false; + FileAccess::set_backup_save(true); @@ -5353,19 +5399,27 @@ EditorNode::EditorNode() { // load settings if (!EditorSettings::get_singleton()) EditorSettings::create(); + + bool use_single_dock_column = false; { int dpi_mode = EditorSettings::get_singleton()->get("global/hidpi_mode"); if (dpi_mode==0) { - editor_set_hidpi( OS::get_singleton()->get_screen_dpi(0) > 150 ); + editor_set_scale( OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x>2000 ? 2.0 : 1.0 ); + + use_single_dock_column = OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x<1200; + + } else if (dpi_mode==1) { + editor_set_scale(0.75); } else if (dpi_mode==2) { - editor_set_hidpi(true); - } else { - editor_set_hidpi(false); + editor_set_scale(1.0); + } else if (dpi_mode==3) { + editor_set_scale(1.5); + } else if (dpi_mode==4) { + editor_set_scale(2.0); } } - ResourceLoader::set_abort_on_missing_resources(false); FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); @@ -5414,9 +5468,9 @@ EditorNode::EditorNode() { theme_base->add_child(gui_base); gui_base->set_area_as_parent_rect(); - theme_base->set_theme( create_default_theme() ); - theme = create_editor_theme(); - gui_base->set_theme(theme); + Ref<Theme> theme = create_editor_theme(); + theme_base->set_theme( theme ); + gui_base->set_theme(create_custom_theme()); resource_preview = memnew( EditorResourcePreview ); add_child(resource_preview); @@ -5672,8 +5726,6 @@ EditorNode::EditorNode() { prev_scene->set_pos(Point2(3,24)); prev_scene->hide(); - ED_SHORTCUT("editor/fullscreen_mode",TTR("Fullscreen Mode"),KEY_MASK_SHIFT|KEY_F11); - ED_SHORTCUT("editor/distraction_free_mode",TTR("Distraction Free Mode"),KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F11); ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD+KEY_TAB); @@ -5744,6 +5796,13 @@ EditorNode::EditorNode() { editor_region->add_child(main_editor_button_vb); menu_hb->add_child(editor_region); + distraction_free = memnew( ToolButton ); + main_editor_button_vb->add_child(distraction_free); + distraction_free->set_shortcut( ED_SHORTCUT("editor/distraction_free_mode",TTR("Distraction Free Mode"),KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F11) ); + distraction_free->connect("pressed",this,"_toggle_distraction_free_mode"); + distraction_free->set_icon(gui_base->get_icon("DistractionFree","EditorIcons")); + distraction_free->set_toggle_mode(true); + //menu_hb->add_spacer(); #if 0 node_menu = memnew( MenuButton ); @@ -5984,6 +6043,9 @@ EditorNode::EditorNode() { p->add_child(editor_layouts); editor_layouts->connect("item_pressed",this,"_layout_menu_option"); p->add_submenu_item(TTR("Editor Layout"), "Layouts"); + + p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode",TTR("Toggle Fullscreen"),KEY_MASK_SHIFT|KEY_F11),SETTINGS_TOGGLE_FULLSCREN); + p->add_separator(); p->add_item(TTR("Install Export Templates"),SETTINGS_LOAD_EXPORT_TEMPLATES); p->add_separator(); @@ -6008,6 +6070,8 @@ EditorNode::EditorNode() { p=update_menu->get_popup(); p->add_check_item(TTR("Update Always"),SETTINGS_UPDATE_ALWAYS); p->add_check_item(TTR("Update Changes"),SETTINGS_UPDATE_CHANGES); + p->add_separator(); + p->add_check_item(TTR("Disable Update Spinner"),SETTINGS_UPDATE_SPINNER_HIDE); p->set_item_checked(1,true); //sources_button->connect(); @@ -6176,12 +6240,24 @@ EditorNode::EditorNode() { node_dock = memnew( NodeDock ); //node_dock->set_undoredo(&editor_data.get_undo_redo()); - dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(node_dock); + if (use_single_dock_column) { + dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(node_dock); + } else { + dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(node_dock); + } scenes_dock = memnew( FileSystemDock(this) ); scenes_dock->set_name(TTR("FileSystem")); scenes_dock->set_display_mode(int(EditorSettings::get_singleton()->get("filesystem_dock/display_mode"))); - dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scenes_dock); + + if (use_single_dock_column) { + dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(scenes_dock); + left_r_vsplit->hide(); + dock_slot[DOCK_SLOT_LEFT_UR]->hide(); + dock_slot[DOCK_SLOT_LEFT_BR]->hide(); + } else { + dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scenes_dock); + } //prop_pallete->add_child(scenes_dock); scenes_dock->connect("open",this,"open_request"); scenes_dock->connect("instance",this,"_instance_request"); @@ -6190,9 +6266,9 @@ EditorNode::EditorNode() { overridden_default_layout=-1; default_layout.instance(); - default_layout->set_value(docks_section, "dock_3", TTR("Scene")); - default_layout->set_value(docks_section, "dock_4", TTR("FileSystem")); - default_layout->set_value(docks_section, "dock_5", TTR("Inspector")); + default_layout->set_value(docks_section, "dock_3", TTR("FileSystem")); + default_layout->set_value(docks_section, "dock_5", TTR("Scene")); + default_layout->set_value(docks_section, "dock_6", TTR("Inspector")+","+TTR("Node")); for(int i=0;i<DOCK_SLOT_MAX/2;i++) default_layout->set_value(docks_section, "dock_hsplit_"+itos(i+1), 0); @@ -6543,11 +6619,6 @@ EditorNode::EditorNode() { Globals::get_singleton()->set("debug/indicators_enabled",true); Globals::get_singleton()->set("render/room_cull_enabled",false); - theme->set_color("prop_category","Editor",Color::hex(0x3f3a44ff)); - theme->set_color("prop_section","Editor",Color::hex(0x35313aff)); - theme->set_color("prop_subsection","Editor",Color::hex(0x312e37ff)); - theme->set_color("fg_selected","Editor",Color::html("ffbd8e8e")); - theme->set_color("fg_error","Editor",Color::html("ffbd8e8e")); reference_resource_mem=true; save_external_resources_mem=true; @@ -6684,45 +6755,54 @@ EditorNode::~EditorNode() { void EditorPluginList::make_visible(bool p_visible) { - if (!plugins_list.empty()) { - for (int i = 0; i < plugins_list.size(); i++) { - plugins_list[i]->make_visible(p_visible); - } + + for (int i = 0; i < plugins_list.size(); i++) { + plugins_list[i]->make_visible(p_visible); } + } void EditorPluginList::edit(Object* p_object) { - if (!plugins_list.empty()) { - for (int i = 0; i < plugins_list.size(); i++) { - plugins_list[i]->edit(p_object); - } + + for (int i = 0; i < plugins_list.size(); i++) { + plugins_list[i]->edit(p_object); } + } -bool EditorPluginList::forward_input_event(const InputEvent& p_event) { +bool EditorPluginList::forward_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) { + bool discard = false; - if (!plugins_list.empty()) { - for (int i = 0; i < plugins_list.size(); i++) { - if (plugins_list[i]->forward_input_event(p_event)) { - discard = true; - } + + for (int i = 0; i < plugins_list.size(); i++) { + if (plugins_list[i]->forward_canvas_input_event(p_canvas_xform,p_event)) { + discard = true; } } + return discard; } bool EditorPluginList::forward_spatial_input_event(Camera* p_camera, const InputEvent& p_event) { bool discard = false; - if (!plugins_list.empty()) { - for (int i = 0; i < plugins_list.size(); i++) { - if (plugins_list[i]->forward_spatial_input_event(p_camera, p_event)) { - discard = true; - } + + for (int i = 0; i < plugins_list.size(); i++) { + if (plugins_list[i]->forward_spatial_input_event(p_camera, p_event)) { + discard = true; } } + return discard; } +void EditorPluginList::forward_draw_over_canvas(const Matrix32& p_canvas_xform,Control* p_canvas) { + + for (int i = 0; i < plugins_list.size(); i++) { + plugins_list[i]->forward_draw_over_canvas(p_canvas_xform,p_canvas); + } + +} + bool EditorPluginList::empty() { return plugins_list.empty(); } diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index e6119cf577..6392b96f8f 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -95,6 +95,7 @@ typedef void (*EditorNodeInitCallback)(); typedef void (*EditorPluginInitializeCallback)(); +typedef void (*EditorBuildCallback)(); class EditorPluginList; @@ -178,6 +179,7 @@ private: RUN_RELOAD_SCRIPTS, SETTINGS_UPDATE_ALWAYS, SETTINGS_UPDATE_CHANGES, + SETTINGS_UPDATE_SPINNER_HIDE, SETTINGS_EXPORT_PREFERENCES, SETTINGS_PREFERENCES, SETTINGS_OPTIMIZED_PRESETS, @@ -186,6 +188,7 @@ private: SETTINGS_LAYOUT_DEFAULT, SETTINGS_LOAD_EXPORT_TEMPLATES, SETTINGS_PICK_MAIN_SCENE, + SETTINGS_TOGGLE_FULLSCREN, SETTINGS_HELP, SETTINGS_ABOUT, SOURCES_REIMPORT, @@ -356,7 +359,7 @@ private: int dock_popup_selected; Timer *dock_drag_timer; bool docks_visible; - bool distraction_free_mode; + ToolButton *distraction_free; String _tmp_import_path; @@ -576,13 +579,21 @@ private: static void _file_access_close_error_notify(const String& p_str); + void _toggle_distraction_free_mode(); enum { - MAX_INIT_CALLBACKS=128 + MAX_INIT_CALLBACKS=128, + MAX_BUILD_CALLBACKS=128 }; + + static int plugin_init_callback_count; static EditorPluginInitializeCallback plugin_init_callbacks[MAX_INIT_CALLBACKS]; + + void _call_build(); + static int build_callback_count; + static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS]; protected: void _notification(int p_what); static void _bind_methods(); @@ -690,6 +701,7 @@ public: void notify_child_process_exited(); + OS::ProcessID get_child_process_id() const { return editor_run.get_pid(); } void stop_child_process(); Ref<Theme> get_editor_theme() const { return theme; } @@ -750,6 +762,7 @@ public: void get_singleton(const char* arg1, bool arg2); static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); } + static void add_build_callback(EditorBuildCallback p_callback); @@ -780,8 +793,9 @@ public: void make_visible(bool p_visible); void edit(Object *p_object); - bool forward_input_event(const InputEvent& p_event); + bool forward_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event); bool forward_spatial_input_event(Camera* p_camera, const InputEvent& p_event); + void forward_draw_over_canvas(const Matrix32& p_canvas_xform,Control* p_canvas); void clear(); bool empty(); diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp index 5e671549ef..4b82d5e59c 100644 --- a/tools/editor/editor_plugin.cpp +++ b/tools/editor/editor_plugin.cpp @@ -32,6 +32,7 @@ #include "plugins/spatial_editor_plugin.h" #include "tools/editor/editor_node.h" #include "tools/editor/editor_settings.h" +#include "editor_resource_preview.h" void EditorPlugin::add_custom_type(const String& p_type, const String& p_base,const Ref<Script>& p_script, const Ref<Texture>& p_icon) { @@ -70,6 +71,11 @@ void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) { } +Control * EditorPlugin::get_editor_viewport() { + + return EditorNode::get_singleton()->get_viewport(); +} + void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Control *p_control) { switch(p_location) { @@ -130,13 +136,25 @@ Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial* p_spatial) { return Ref<SpatialEditorGizmo>(); } -bool EditorPlugin::forward_input_event(const InputEvent& p_event) { +bool EditorPlugin::forward_canvas_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) { - if (get_script_instance() && get_script_instance()->has_method("forward_input_event")) { - return get_script_instance()->call("forward_input_event",p_event); + if (get_script_instance() && get_script_instance()->has_method("forward_canvas_input_event")) { + return get_script_instance()->call("forward_canvas_input_event",p_canvas_xform,p_event); } return false; } + +void EditorPlugin::forward_draw_over_canvas(const Matrix32& p_canvas_xform,Control *p_canvas) { + + if (get_script_instance() && get_script_instance()->has_method("forward_draw_over_canvas")) { + get_script_instance()->call("forward_draw_over_canvas",p_canvas_xform,p_canvas); + } +} + +void EditorPlugin::update_canvas() { + CanvasItemEditor::get_singleton()->get_viewport_control()->update(); +} + bool EditorPlugin::forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event) { if (get_script_instance() && get_script_instance()->has_method("forward_spatial_input_event")) { @@ -272,6 +290,10 @@ EditorSettings *EditorPlugin::get_editor_settings() { return EditorSettings::get_singleton(); } +EditorResourcePreview *EditorPlugin::get_resource_previewer() { + return EditorResourcePreview::get_singleton(); +} + void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin>& p_editor_import) { EditorNode::get_singleton()->add_editor_import_plugin(p_editor_import); @@ -298,6 +320,24 @@ Control *EditorPlugin::get_base_control() { return EditorNode::get_singleton()->get_gui_base(); } +void EditorPlugin::make_bottom_panel_item_visible(Control * p_item) { + + EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item); +} + +void EditorPlugin::hide_bottom_panel() { + + EditorNode::get_singleton()->hide_bottom_panel(); +} + +void EditorPlugin::inspect_object(Object *p_obj,const String& p_for_property) { + + EditorNode::get_singleton()->push_item(p_obj,p_for_property); +} + +EditorFileSystem *EditorPlugin::get_resource_file_system() { + return EditorFileSystem::get_singleton(); +} void EditorPlugin::_bind_methods() { @@ -308,6 +348,7 @@ void EditorPlugin::_bind_methods() { ObjectTypeDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel); ObjectTypeDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type); ObjectTypeDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type); + ObjectTypeDB::bind_method(_MD("get_editor_viewport:Control"), &EditorPlugin::get_editor_viewport); ObjectTypeDB::bind_method(_MD("add_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::add_import_plugin); ObjectTypeDB::bind_method(_MD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::remove_import_plugin); @@ -315,6 +356,14 @@ void EditorPlugin::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::add_export_plugin); ObjectTypeDB::bind_method(_MD("remove_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::remove_export_plugin); + ObjectTypeDB::bind_method(_MD("get_resource_previewer:EditorResourcePreview"),&EditorPlugin::get_resource_previewer); + ObjectTypeDB::bind_method(_MD("get_resource_filesystem:EditorFileSystem"),&EditorPlugin::get_resource_file_system); + + ObjectTypeDB::bind_method(_MD("inspect_object","object","for_property"),&EditorPlugin::inspect_object,DEFVAL(String())); + ObjectTypeDB::bind_method(_MD("update_canvas"),&EditorPlugin::update_canvas); + + ObjectTypeDB::bind_method(_MD("make_bottom_panel_item_visible","item:Control"), &EditorPlugin::make_bottom_panel_item_visible); + ObjectTypeDB::bind_method(_MD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel); ObjectTypeDB::bind_method(_MD("get_base_control:Control"),&EditorPlugin::get_base_control); ObjectTypeDB::bind_method(_MD("get_undo_redo:UndoRedo"),&EditorPlugin::_get_undo_redo); @@ -322,7 +371,8 @@ void EditorPlugin::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_editor_settings:EditorSettings"),&EditorPlugin::get_editor_settings); ObjectTypeDB::bind_method(_MD("queue_save_layout"),&EditorPlugin::queue_save_layout); - ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_input_event",PropertyInfo(Variant::INPUT_EVENT,"event"))); + ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_canvas_input_event",PropertyInfo(Variant::MATRIX32,"canvas_xform"),PropertyInfo(Variant::INPUT_EVENT,"event"))); + ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("forward_draw_over_canvas",PropertyInfo(Variant::MATRIX32,"canvas_xform"),PropertyInfo(Variant::OBJECT,"canvas:Control"))); ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_spatial_input_event",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera"),PropertyInfo(Variant::INPUT_EVENT,"event"))); MethodInfo gizmo = MethodInfo(Variant::OBJECT,"create_spatial_gizmo",PropertyInfo(Variant::OBJECT,"for_spatial:Spatial")); gizmo.return_val.hint=PROPERTY_HINT_RESOURCE_TYPE; diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h index 9a9c32357d..2700c49a6c 100644 --- a/tools/editor/editor_plugin.h +++ b/tools/editor/editor_plugin.h @@ -34,6 +34,7 @@ #include "scene/resources/texture.h" #include "undo_redo.h" #include "io/config_file.h" + /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -47,6 +48,8 @@ class EditorSettings; class SpatialEditorGizmo; class EditorImportPlugin; class EditorExportPlugin; +class EditorResourcePreview; +class EditorFileSystem; class EditorPlugin : public Node { @@ -97,9 +100,11 @@ public: void add_control_to_dock(DockSlot p_slot,Control *p_control); void remove_control_from_docks(Control *p_control); void remove_control_from_bottom_panel(Control *p_control); + Control* get_editor_viewport(); virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial); - virtual bool forward_input_event(const InputEvent& p_event); + virtual bool forward_canvas_input_event(const Matrix32& p_canvas_xform, const InputEvent& p_event); + virtual void forward_draw_over_canvas(const Matrix32& p_canvas_xform,Control *p_canvas); virtual bool forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event); virtual String get_name() const; virtual bool has_main_screen() const; @@ -116,12 +121,19 @@ public: virtual bool get_remove_list(List<Node*> *p_list); virtual void set_window_layout(Ref<ConfigFile> p_layout); virtual void get_window_layout(Ref<ConfigFile> p_layout); - virtual void edited_scene_changed(){}; // if changes are pending in editor, apply them + virtual void edited_scene_changed(){} // if changes are pending in editor, apply them + + void update_canvas(); + + virtual void inspect_object(Object *p_obj,const String& p_for_property=String()); void queue_save_layout() const; Control *get_base_control(); + void make_bottom_panel_item_visible(Control *p_item); + void hide_bottom_panel(); + void add_import_plugin(const Ref<EditorImportPlugin>& p_editor_import); void remove_import_plugin(const Ref<EditorImportPlugin>& p_editor_import); @@ -131,6 +143,8 @@ public: EditorSelection* get_selection(); //EditorImportExport *get_import_export(); EditorSettings *get_editor_settings(); + EditorResourcePreview *get_resource_previewer(); + EditorFileSystem *get_resource_file_system(); virtual void restore_global_state(); virtual void save_global_state(); diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index a02fe2a531..6afc3e2a34 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -35,14 +35,46 @@ #include "editor_scale.h" #include "message_queue.h" +bool EditorResourcePreviewGenerator::handles(const String& p_type) const { + + if (get_script_instance() && get_script_instance()->has_method("handles")) { + return get_script_instance()->call("handles",p_type); + } + ERR_EXPLAIN("EditorResourcePreviewGenerator::handles needs to be overriden"); + ERR_FAIL_V(false); +} +Ref<Texture> EditorResourcePreviewGenerator::generate(const RES& p_from){ + + if (get_script_instance() && get_script_instance()->has_method("generate")) { + return get_script_instance()->call("generate",p_from); + } + ERR_EXPLAIN("EditorResourcePreviewGenerator::generate needs to be overriden"); + ERR_FAIL_V(Ref<Texture>()); + +} + + Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String& p_path) { + if (get_script_instance() && get_script_instance()->has_method("generate_from_path")) { + return get_script_instance()->call("generate_from_path",p_path); + } + RES res = ResourceLoader::load(p_path); if (!res.is_valid()) return res; return generate(res); } + +void EditorResourcePreviewGenerator::_bind_methods() { + + ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"handles",PropertyInfo(Variant::STRING,"type"))); + ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::OBJECT,"generate:Texture",PropertyInfo(Variant::OBJECT,"from",PROPERTY_HINT_RESOURCE_TYPE,"Resource"))); + ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::OBJECT,"generate_from_path:Texture",PropertyInfo(Variant::STRING,"path",PROPERTY_HINT_FILE))); + +} + EditorResourcePreviewGenerator::EditorResourcePreviewGenerator() { @@ -330,6 +362,11 @@ void EditorResourcePreview::add_preview_generator(const Ref<EditorResourcePrevie preview_generators.push_back(p_generator); } +void EditorResourcePreview::remove_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator) { + + preview_generators.erase(p_generator); +} + EditorResourcePreview* EditorResourcePreview::get_singleton() { return singleton; @@ -338,6 +375,11 @@ EditorResourcePreview* EditorResourcePreview::get_singleton() { void EditorResourcePreview::_bind_methods() { ObjectTypeDB::bind_method("_preview_ready",&EditorResourcePreview::_preview_ready); + + ObjectTypeDB::bind_method(_MD("queue_resource_preview","path","receiver","receiver_func","userdata:Variant"),&EditorResourcePreview::queue_resource_preview); + ObjectTypeDB::bind_method(_MD("queue_edited_resource_preview","resource:Resource","receiver","receiver_func","userdata:Variant"),&EditorResourcePreview::queue_edited_resource_preview); + ObjectTypeDB::bind_method(_MD("add_preview_generator","generator:EditorResourcePreviewGenerator"),&EditorResourcePreview::add_preview_generator); + ObjectTypeDB::bind_method(_MD("remove_preview_generator","generator:EditorResourcePreviewGenerator"),&EditorResourcePreview::remove_preview_generator); ObjectTypeDB::bind_method(_MD("check_for_invalidation","path"),&EditorResourcePreview::check_for_invalidation); diff --git a/tools/editor/editor_resource_preview.h b/tools/editor/editor_resource_preview.h index 51a00965eb..2756360130 100644 --- a/tools/editor/editor_resource_preview.h +++ b/tools/editor/editor_resource_preview.h @@ -57,10 +57,13 @@ class EditorResourcePreviewGenerator : public Reference { OBJ_TYPE(EditorResourcePreviewGenerator,Reference ); +protected: + + static void _bind_methods(); public: - virtual bool handles(const String& p_type) const=0; - virtual Ref<Texture> generate(const RES& p_from)=0; + virtual bool handles(const String& p_type) const; + virtual Ref<Texture> generate(const RES& p_from); virtual Ref<Texture> generate_from_path(const String& p_path); EditorResourcePreviewGenerator(); @@ -121,6 +124,7 @@ public: void queue_edited_resource_preview(const Ref<Resource>& p_path, Object* p_receiver, const StringName& p_receiver_func, const Variant& p_userdata); void add_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator); + void remove_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator); void check_for_invalidation(const String& p_path); EditorResourcePreview(); diff --git a/tools/editor/editor_run.cpp b/tools/editor/editor_run.cpp index fb0f24c084..5fbb4ae2a0 100644 --- a/tools/editor/editor_run.cpp +++ b/tools/editor/editor_run.cpp @@ -52,6 +52,9 @@ Error EditorRun::run(const String& p_scene,const String p_custom_args,const List args.push_back("localhost:"+String::num(GLOBAL_DEF("debug/debug_port", 6007))); } + args.push_back("-epid"); + args.push_back(String::num(OS::get_singleton()->get_process_ID())); + if (p_custom_args!="") { Vector<String> cargs=p_custom_args.split(" ",false); @@ -132,6 +135,7 @@ Error EditorRun::run(const String& p_scene,const String p_custom_args,const List } + if (p_breakpoints.size()) { args.push_back("-bp"); diff --git a/tools/editor/editor_run.h b/tools/editor/editor_run.h index 0b96a2c91c..5aa2adf801 100644 --- a/tools/editor/editor_run.h +++ b/tools/editor/editor_run.h @@ -53,6 +53,8 @@ public: void run_native_notify() { status=STATUS_PLAY; } void stop(); + OS::ProcessID get_pid() const { return pid; } + void set_debug_collisions(bool p_debug); bool get_debug_collisions() const; diff --git a/tools/editor/editor_scale.cpp b/tools/editor/editor_scale.cpp index c332acc0ca..8575e1c30a 100644 --- a/tools/editor/editor_scale.cpp +++ b/tools/editor/editor_scale.cpp @@ -1,14 +1,13 @@ #include "editor_scale.h" #include "os/os.h" -static bool editor_hidpi=false; +static float scale = 1.0; -void editor_set_hidpi(bool p_hidpi) { +void editor_set_scale(float p_scale) { - editor_hidpi=p_hidpi; + scale=p_scale; } +float editor_get_scale() { -bool editor_is_hidpi() { - - return editor_hidpi; + return scale; } diff --git a/tools/editor/editor_scale.h b/tools/editor/editor_scale.h index a60cf00f0a..90e575f771 100644 --- a/tools/editor/editor_scale.h +++ b/tools/editor/editor_scale.h @@ -1,8 +1,8 @@ #ifndef EDITOR_SCALE_H #define EDITOR_SCALE_H -void editor_set_hidpi(bool p_hidpi); -bool editor_is_hidpi(); +void editor_set_scale(float p_scale); +float editor_get_scale(); -#define EDSCALE (editor_is_hidpi() ? 2 : 1) +#define EDSCALE (editor_get_scale()) #endif // EDITOR_SCALE_H diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 99c80fdc36..a5ba4847f5 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -511,7 +511,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { } set("global/hidpi_mode",0); - hints["global/hidpi_mode"]=PropertyInfo(Variant::INT,"global/hidpi_mode",PROPERTY_HINT_ENUM,"Auto,LoDPI,HiDPI",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); + hints["global/hidpi_mode"]=PropertyInfo(Variant::INT,"global/hidpi_mode",PROPERTY_HINT_ENUM,"Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); set("global/show_script_in_scene_tabs",false); set("global/font_size",14); hints["global/font_size"]=PropertyInfo(Variant::INT,"global/font_size",PROPERTY_HINT_RANGE,"10,40,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); @@ -565,8 +565,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("text_editor/restore_scripts_on_load",true); - set("scenetree_editor/duplicate_node_name_num_separator",0); - hints["scenetree_editor/duplicate_node_name_num_separator"]=PropertyInfo(Variant::INT,"scenetree_editor/duplicate_node_name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"); //set("scenetree_editor/display_old_action_buttons",false); set("scenetree_editor/start_create_dialog_fully_expanded",false); set("scenetree_editor/draw_relationship_lines",false); @@ -574,6 +572,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("grid_map/pick_distance", 5000.0); + set("3d_editor/grid_color",Color(0,1,0,0.2)); + hints["3d_editor/grid_color"]=PropertyInfo(Variant::COLOR,"3d_editor/grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); + set("3d_editor/default_fov",45.0); set("3d_editor/default_z_near",0.1); set("3d_editor/default_z_far",500.0); diff --git a/tools/editor/editor_themes.cpp b/tools/editor/editor_themes.cpp index 44e21aee85..08f14ec167 100644 --- a/tools/editor/editor_themes.cpp +++ b/tools/editor/editor_themes.cpp @@ -32,8 +32,9 @@ #include "editor_fonts.h" #include "editor_settings.h" #include "core/io/resource_loader.h" +#include "editor_scale.h" -Ref<Theme> create_default_theme() +Ref<Theme> create_editor_theme() { Ref<Theme> theme = Ref<Theme>( memnew( Theme ) ); @@ -43,32 +44,36 @@ Ref<Theme> create_default_theme() Ref<StyleBoxTexture> focus_sbt=memnew( StyleBoxTexture ); focus_sbt->set_texture(theme->get_icon("EditorFocus","EditorIcons")); for(int i=0;i<4;i++) { - focus_sbt->set_margin_size(Margin(i),16); - focus_sbt->set_default_margin(Margin(i),16); + focus_sbt->set_margin_size(Margin(i),16*EDSCALE); + focus_sbt->set_default_margin(Margin(i),16*EDSCALE); } focus_sbt->set_draw_center(false); theme->set_stylebox("EditorFocus","EditorStyles",focus_sbt); + theme->set_color("prop_category","Editor",Color::hex(0x3f3a44ff)); + theme->set_color("prop_section","Editor",Color::hex(0x35313aff)); + theme->set_color("prop_subsection","Editor",Color::hex(0x312e37ff)); + theme->set_color("fg_selected","Editor",Color::html("ffbd8e8e")); + theme->set_color("fg_error","Editor",Color::html("ffbd8e8e")); return theme; } -Ref<Theme> create_editor_theme() +Ref<Theme> create_custom_theme() { - Ref<Theme> theme = NULL; + Ref<Theme> theme; String custom_theme = EditorSettings::get_singleton()->get("global/custom_theme"); if (custom_theme!="") { theme = ResourceLoader::load(custom_theme); } - if (theme.is_null() || !theme.is_valid()) { - theme = create_default_theme(); - } - String global_font = EditorSettings::get_singleton()->get("global/custom_font"); if (global_font!="") { Ref<Font> fnt = ResourceLoader::load(global_font); if (fnt.is_valid()) { + if (!theme.is_valid()) { + theme.instance(); + } theme->set_default_theme_font(fnt); } } diff --git a/tools/editor/editor_themes.h b/tools/editor/editor_themes.h index dbff8b3079..db49801600 100644 --- a/tools/editor/editor_themes.h +++ b/tools/editor/editor_themes.h @@ -31,8 +31,8 @@ #include "scene/resources/theme.h" -Ref<Theme> create_default_theme(); - Ref<Theme> create_editor_theme(); +Ref<Theme> create_custom_theme(); + #endif diff --git a/tools/editor/icons/2x/icon_distraction_free.png b/tools/editor/icons/2x/icon_distraction_free.png Binary files differnew file mode 100644 index 0000000000..034239a4e7 --- /dev/null +++ b/tools/editor/icons/2x/icon_distraction_free.png diff --git a/tools/editor/icons/2x/icon_mini_aabb.png b/tools/editor/icons/2x/icon_mini_aabb.png Binary files differindex f0fd5620e9..25603eec49 100644 --- a/tools/editor/icons/2x/icon_mini_aabb.png +++ b/tools/editor/icons/2x/icon_mini_aabb.png diff --git a/tools/editor/icons/2x/icon_mini_transform.png b/tools/editor/icons/2x/icon_mini_transform.png Binary files differindex cb106ba5fa..5144871c5c 100644 --- a/tools/editor/icons/2x/icon_mini_transform.png +++ b/tools/editor/icons/2x/icon_mini_transform.png diff --git a/tools/editor/icons/2x/icon_remote_transform.png b/tools/editor/icons/2x/icon_remote_transform.png Binary files differnew file mode 100644 index 0000000000..dad528615a --- /dev/null +++ b/tools/editor/icons/2x/icon_remote_transform.png diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index bc104294cb..44e28f49e6 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -61,8 +61,10 @@ def make_editor_icons_action(target, source, env): s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") - s.write("\tImage img((editor_is_hidpi()&&p_hidpi_png)?p_hidpi_png:p_png);\n") - s.write("\tif (editor_is_hidpi() && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); }\n") + s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") + s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") + s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") + s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") s.write("\treturn texture;\n") s.write("}\n\n") diff --git a/tools/editor/icons/icon_color_frame.png b/tools/editor/icons/icon_color_frame.png Binary files differnew file mode 100644 index 0000000000..a82eefc10a --- /dev/null +++ b/tools/editor/icons/icon_color_frame.png diff --git a/tools/editor/icons/icon_distraction_free.png b/tools/editor/icons/icon_distraction_free.png Binary files differnew file mode 100644 index 0000000000..c6f8a08874 --- /dev/null +++ b/tools/editor/icons/icon_distraction_free.png diff --git a/tools/editor/icons/icon_mini_aabb.png b/tools/editor/icons/icon_mini_aabb.png Binary files differindex 3a6be5605a..eebc4633e4 100644 --- a/tools/editor/icons/icon_mini_aabb.png +++ b/tools/editor/icons/icon_mini_aabb.png diff --git a/tools/editor/icons/icon_mini_transform.png b/tools/editor/icons/icon_mini_transform.png Binary files differindex 0107107a96..068ea0506c 100644 --- a/tools/editor/icons/icon_mini_transform.png +++ b/tools/editor/icons/icon_mini_transform.png diff --git a/tools/editor/icons/icon_remote_transform.png b/tools/editor/icons/icon_remote_transform.png Binary files differnew file mode 100644 index 0000000000..2a8b5f4d0e --- /dev/null +++ b/tools/editor/icons/icon_remote_transform.png diff --git a/tools/editor/icons/source/icon_distraction_free.svg b/tools/editor/icons/source/icon_distraction_free.svg new file mode 100644 index 0000000000..4ae48b2fb6 --- /dev/null +++ b/tools/editor/icons/source/icon_distraction_free.svg @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + viewBox="0 0 16 16" + id="svg2" + version="1.1" + inkscape:version="0.91 r13725" + inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png" + inkscape:export-xdpi="45" + inkscape:export-ydpi="45" + sodipodi:docname="icon_distraction_free.svg"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="32.000001" + inkscape:cx="10.344519" + inkscape:cy="8.9631686" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + units="px" + inkscape:snap-bbox="true" + inkscape:bbox-paths="true" + inkscape:bbox-nodes="true" + inkscape:snap-bbox-edge-midpoints="true" + inkscape:snap-bbox-midpoints="false" + inkscape:snap-object-midpoints="true" + inkscape:snap-center="true" + inkscape:window-width="1920" + inkscape:window-height="1016" + inkscape:window-x="0" + inkscape:window-y="27" + inkscape:window-maximized="1" + inkscape:snap-midpoints="true" + inkscape:snap-smooth-nodes="true" + inkscape:object-nodes="true"> + <inkscape:grid + type="xygrid" + id="grid3336" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1036.3622)"> + <path + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 3.7578125 2.34375 L 2.34375 3.7578125 L 5.2929688 6.7070312 L 6.7070312 5.2929688 L 3.7578125 2.34375 z M 12.242188 2.34375 L 9.2929688 5.2929688 L 10.707031 6.7070312 L 13.65625 3.7578125 L 12.242188 2.34375 z M 5.2929688 9.2929688 L 2.34375 12.242188 L 3.7578125 13.65625 L 6.7070312 10.707031 L 5.2929688 9.2929688 z M 10.707031 9.2929688 L 9.2929688 10.707031 L 12.242188 13.65625 L 13.65625 12.242188 L 10.707031 9.2929688 z " + transform="translate(0,1036.3622)" + id="rect4137" /> + <path + style="fill:#e0e0e0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 1,1051.3622 0,-5 5,5 z" + id="path4155" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> + <path + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" + id="path4158" + d="m 15,1051.3622 0,-5 -5,5 z" + style="fill:#e0e0e0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + <path + style="fill:#e0e0e0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 15,1037.3622 0,5 -5,-5 z" + id="path4160" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> + <path + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" + id="path4162" + d="m 1,1037.3622 0,5 5,-5 z" + style="fill:#e0e0e0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + </g> +</svg> diff --git a/tools/editor/icons/source/icon_mini_aabb.svg b/tools/editor/icons/source/icon_mini_aabb.svg index f6cc3feda1..ebfd505bea 100644 --- a/tools/editor/icons/source/icon_mini_aabb.svg +++ b/tools/editor/icons/source/icon_mini_aabb.svg @@ -29,8 +29,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="45.254835" - inkscape:cx="3.148993" - inkscape:cy="6.4579802" + inkscape:cx="5.0272453" + inkscape:cy="5.132155" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -76,7 +76,7 @@ id="path4893" inkscape:connector-curvature="0" /> <path - style="fill:#f5acbb;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + style="fill:#f39bad;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 3,1046.3622 a 3,3 0 0 0 -3,3 3,3 0 0 0 3,3 l 2,0 0,-6 -2,0 z m 0,2 0,2 a 1.0000174,1.0000174 0 0 1 -1,-1 1.0000174,1.0000174 0 0 1 1,-1 z" id="path4234" inkscape:connector-curvature="0" /> @@ -99,7 +99,7 @@ id="rect4149" style="fill:#ee7991;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> <path - style="fill:#f5acbb;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + style="fill:#f39bad;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 8,1044.3622 0,8 2,0 a 3,3 0 0 0 3,-3 3,3 0 0 0 -3,-3 l 0,-2 -2,0 z m 2,4 a 1.0000174,1.0000174 0 0 1 1,1 1.0000174,1.0000174 0 0 1 -1,1 l 0,-2 z" id="path4151" inkscape:connector-curvature="0" /> diff --git a/tools/editor/icons/source/icon_mini_transform.svg b/tools/editor/icons/source/icon_mini_transform.svg index a844171dd4..6da4eb806d 100644 --- a/tools/editor/icons/source/icon_mini_transform.svg +++ b/tools/editor/icons/source/icon_mini_transform.svg @@ -29,8 +29,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="32" - inkscape:cx="5.8969613" - inkscape:cy="6.372864" + inkscape:cx="8.2643591" + inkscape:cy="7.6152896" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -71,26 +71,20 @@ id="layer1" transform="translate(0,-1040.3622)"> <path - style="fill:#f3e49c;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 3,1042.3622 a 3,3 0 0 0 -3,3 l 0,5 2,0 0,-2 1,0 0,-2 -1,0 0,-1 a 1.0000174,1.0000174 0 0 1 1,-1 l 0,-2 z" - id="rect4455" - inkscape:connector-curvature="0" /> + style="fill:#f6a86e;fill-opacity:1;stroke:none;stroke-width:20;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 4,1042.3622 3.0917969,1044.5438 2,1042.3622 l -2,0 2,4 -2,4 2,0 0.9082031,-2.1816 L 4,1050.3622 l 2,0 -2,-4 2,-4 z" + id="rect4214" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccccccccc" /> <path - style="fill:#ecd669;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 8,1044.3622 0,6 2,0 0,-4 a 1.0000174,1.0000174 0 0 1 1,1 l 0,3 2,0 0,-3 0,-1 a 1.0000174,1.0000174 0 0 1 1,1 l 0,3 2,0 0,-3 a 3,3 0 0 0 -3,-3 l -2,0 0,0.1758 a 3,3 0 0 0 -1,-0.1758 l -2,0 z" - id="path4771" + style="fill:#f8bf95;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 9,1042.3622 a 3,3 0 0 0 -3,3 l 0,5 2,0 0,-2 1,0 0,-2 -1,0 0,-1 a 1.0000174,1.0000174 0 0 1 1,-1 l 1,0 0,-2 -1,0 z" + id="rect4455" inkscape:connector-curvature="0" /> <path - style="fill:#ecd669;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 7,1044.3622 a 3,3 0 0 0 -3,3 l 0,3 2,0 0,-3 a 1.0000174,1.0000174 0 0 1 1,-1 l 0,-2 z" - id="rect4601" - inkscape:connector-curvature="0" /> - <rect - style="fill:#f3e49c;fill-opacity:1;stroke:none" - id="rect4139" - width="1" - height="2" - x="3" - y="1042.3622" /> + style="fill:#f6a86e;fill-opacity:1;stroke:none;stroke-width:20;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 10 4 L 10 6 L 10 8 L 10 10 L 12 10 L 12 8 L 13 9 L 14 8 L 14 10 L 16 10 L 16 8 L 16 6 L 16 4 L 14 4 L 13 6 L 12 4 L 10 4 z " + transform="translate(0,1040.3622)" + id="rect4231" /> </g> </svg> diff --git a/tools/editor/icons/source/icon_remote_transform.svg b/tools/editor/icons/source/icon_remote_transform.svg new file mode 100644 index 0000000000..fbbfacf629 --- /dev/null +++ b/tools/editor/icons/source/icon_remote_transform.svg @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + viewBox="0 0 16 16" + id="svg2" + version="1.1" + inkscape:version="0.91 r13725" + inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_node_2d.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + sodipodi:docname="icon_remote_transform.svg"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="16" + inkscape:cx="7.0691739" + inkscape:cy="9.3738931" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + units="px" + inkscape:snap-bbox="true" + inkscape:bbox-paths="true" + inkscape:bbox-nodes="true" + inkscape:snap-bbox-edge-midpoints="true" + inkscape:snap-bbox-midpoints="true" + inkscape:snap-object-midpoints="true" + inkscape:snap-center="true" + inkscape:window-width="1680" + inkscape:window-height="1050" + inkscape:window-x="1366" + inkscape:window-y="0" + inkscape:window-maximized="1" + inkscape:object-paths="true" + inkscape:snap-intersection-paths="true" + inkscape:object-nodes="true" + inkscape:snap-smooth-nodes="true"> + <inkscape:grid + type="xygrid" + id="grid3336" + empspacing="4" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1036.3622)"> + <path + style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path4155" + sodipodi:type="arc" + sodipodi:cx="744.13245" + sodipodi:cy="734.23291" + sodipodi:rx="4" + sodipodi:ry="4" + sodipodi:start="0" + sodipodi:end="3.1415927" + d="m 748.13245,734.23291 a 4,4 0 0 1 -2,3.4641 4,4 0 0 1 -4,0 4,4 0 0 1 -2,-3.4641 l 4,0 z" + inkscape:transform-center-y="0.58575321" + transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,0,0)" + inkscape:transform-center-x="0.58575732" /> + <circle + style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path4159" + cx="7" + cy="1045.3622" + r="1" /> + <path + style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + d="m 13.242641,1039.1196 a 6.0000172,6.0000172 0 0 0 -8.4852817,0 l 0.7071068,0.7071 a 5.0000172,5.0000172 0 0 1 7.0710679,0 5.0000172,5.0000172 0 0 1 0,7.071 l 0.707107,0.7071 a 6.0000172,6.0000172 0 0 0 0,-8.4852 z" + id="circle4163" + inkscape:connector-curvature="0" + inkscape:transform-center-y="-0.87867618" + inkscape:transform-center-x="-0.8786559" /> + <path + style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + d="m 11.828427,1040.5338 a 4.0000172,4.0000172 0 0 0 -5.6568541,0 l 0.7071068,0.7071 a 3.0000174,3.0000174 0 0 1 4.2426403,0 3.0000174,3.0000174 0 0 1 0,4.2426 l 0.707107,0.7071 a 4.0000172,4.0000172 0 0 0 0,-5.6568 z" + id="circle4168" + inkscape:connector-curvature="0" + inkscape:transform-center-y="-0.58578284" + inkscape:transform-center-x="-0.58576926" /> + <path + style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + d="m 10.414214,1041.948 a 2,2 0 0 0 -2.8284276,0 l 0.7071068,0.7071 a 1.0000174,1.0000174 0 0 1 1.4142136,0 1.0000174,1.0000174 0 0 1 0,1.4142 l 0.7071072,0.7071 a 2,2 0 0 0 0,-2.8284 z" + id="circle4172" + inkscape:connector-curvature="0" + inkscape:transform-center-y="-0.29289334" + inkscape:transform-center-x="-0.29288664" /> + <path + style="fill:#fc9c9c;fill-opacity:0.99607843;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 1,1051.3622 4,-5 1,0 0,5 z" + id="path4181" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccc" /> + </g> +</svg> diff --git a/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp b/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp index dca7d011ff..757d2ed5d4 100644 --- a/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp @@ -147,7 +147,7 @@ public: dst = dst.plus_file(bitmasks[i].get_file().basename() + ".pbm"); - Error err = plugin->import(dst, imd); + plugin->import(dst, imd); } hide(); diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp index ac0795f522..7dc74e58dd 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -298,7 +298,7 @@ public: dst = dst.plus_file(samples[i].get_file().basename()+".smp"); - Error err = plugin->import(dst,imd); + plugin->import(dst,imd); } hide(); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index fa62283e37..190b56faba 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -1447,6 +1447,7 @@ void EditorSceneImportPlugin::_find_resources(const Variant& p_var, Map<Ref<Imag } } break; + default: {} } @@ -2325,7 +2326,7 @@ void EditorSceneImportPlugin::_filter_tracks(Node *scene, const String& p_text) if (!scene->has_node(String("AnimationPlayer"))) return; - Node* n = scene->get_node(String("AnimationPlayer")); + Node* n = scene->get_node(String("AnimationPlayer")); ERR_FAIL_COND(!n); AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); ERR_FAIL_COND(!anim); @@ -2443,7 +2444,7 @@ void EditorSceneImportPlugin::_optimize_animations(Node *scene, float p_max_lin_ if (!scene->has_node(String("AnimationPlayer"))) return; - Node* n = scene->get_node(String("AnimationPlayer")); + Node* n = scene->get_node(String("AnimationPlayer")); ERR_FAIL_COND(!n); AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); ERR_FAIL_COND(!anim); @@ -2842,7 +2843,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c } } - Error err = EditorTextureImportPlugin::get_singleton()->import(target_path,imd); + EditorTextureImportPlugin::get_singleton()->import(target_path,imd); } } diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 60642999f2..2935ea8fe2 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -38,6 +38,7 @@ #include "scene/gui/check_button.h" #include "scene/gui/button_group.h" #include "scene/gui/margin_container.h" +#include "scene/io/resource_format_image.h" static const char *flag_names[]={ ("Streaming Format"), @@ -1589,16 +1590,9 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c } break; //use default } + String validated_path=EditorImportPlugin::validate_source_path(p_path); - int flags=0; - - if (Globals::get_singleton()->get("image_loader/filter")) - flags|=IMAGE_FLAG_FILTER; - if (!Globals::get_singleton()->get("image_loader/gen_mipmaps")) - flags|=IMAGE_FLAG_NO_MIPMAPS; - if (!Globals::get_singleton()->get("image_loader/repeat")) - flags|=IMAGE_FLAG_REPEAT; - + int flags=texture_flags_to_export_flags(ResourceFormatLoaderImage::load_image_flags(validated_path)); flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; print_line("group format"+itos(group_format)); @@ -1607,7 +1601,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c rimd->set_option("quality",group_lossy_quality); rimd->set_option("atlas",false); rimd->set_option("shrink",group_shrink); - rimd->add_source(EditorImportPlugin::validate_source_path(p_path),FileAccess::get_md5(p_path)); + rimd->add_source(validated_path,FileAccess::get_md5(p_path)); } else if (EditorImportExport::get_singleton()->get_image_formats().has(p_path.extension().to_lower()) && EditorImportExport::get_singleton()->get_export_image_action()!=EditorImportExport::IMAGE_ACTION_NONE) { //handled by general image export settings @@ -1619,22 +1613,16 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: rimd->set_option("format",IMAGE_FORMAT_COMPRESS_RAM); break; } - int flags=0; - - if (Globals::get_singleton()->get("image_loader/filter")) - flags|=IMAGE_FLAG_FILTER; - if (!Globals::get_singleton()->get("image_loader/gen_mipmaps")) - flags|=IMAGE_FLAG_NO_MIPMAPS; - if (!Globals::get_singleton()->get("image_loader/repeat")) - flags|=IMAGE_FLAG_REPEAT; + String validated_path=EditorImportPlugin::validate_source_path(p_path); + int flags=texture_flags_to_export_flags(ResourceFormatLoaderImage::load_image_flags(validated_path)); flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; rimd->set_option("shrink",EditorImportExport::get_singleton()->get_export_image_shrink()); rimd->set_option("flags",flags); rimd->set_option("quality",EditorImportExport::get_singleton()->get_export_image_quality()); rimd->set_option("atlas",false); - rimd->add_source(EditorImportPlugin::validate_source_path(p_path),FileAccess::get_md5(p_path)); + rimd->add_source(validated_path,FileAccess::get_md5(p_path)); } else { return Vector<uint8_t>(); @@ -1726,6 +1714,33 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c return ret; } +uint32_t EditorTextureImportPlugin::texture_flags_to_export_flags(uint32_t p_tex_flags) const { + + uint32_t flags=0; + + if (!(p_tex_flags&Texture::FLAG_MIPMAPS)) { + flags|=IMAGE_FLAG_NO_MIPMAPS; + } + if (p_tex_flags&Texture::FLAG_REPEAT) { + flags|=IMAGE_FLAG_REPEAT; + } + if (p_tex_flags&Texture::FLAG_FILTER) { + flags|=IMAGE_FLAG_FILTER; + } + if (p_tex_flags&Texture::FLAG_ANISOTROPIC_FILTER) { + flags|=IMAGE_FLAG_USE_ANISOTROPY; + } + if (p_tex_flags&Texture::FLAG_CONVERT_TO_LINEAR) { + flags|=IMAGE_FLAG_CONVERT_TO_LINEAR; + } + /* // no correspondence yet + if (p_tex_flags&Texture::TEXTURE_FLAG_MIRRORED_REPEAT) { + flags|=; + }*/ + + return flags; +} + void EditorTextureImportPlugin::import_from_drop(const Vector<String>& p_drop,const String& p_dest_path) { Vector<String> valid; diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.h b/tools/editor/io_plugins/editor_texture_import_plugin.h index 5c8abd10a4..22c10a1a3a 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.h +++ b/tools/editor/io_plugins/editor_texture_import_plugin.h @@ -72,6 +72,8 @@ private: Error _process_texture_data(Ref<ImageTexture> &texture, int format, float quality, int flags,EditorExportPlatform::ImageCompression p_compr,int tex_flags,float shrink); void compress_image(EditorExportPlatform::ImageCompression p_mode,Image& image,bool p_smaller); + + uint32_t texture_flags_to_export_flags(uint32_t p_tex_flags) const; public: diff --git a/tools/editor/multi_node_edit.cpp b/tools/editor/multi_node_edit.cpp index 4d27b8e349..e4ceaf4a8b 100644 --- a/tools/editor/multi_node_edit.cpp +++ b/tools/editor/multi_node_edit.cpp @@ -53,7 +53,14 @@ bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){ if (!n) continue; - ur->add_do_property(n,name,p_value); + if (p_value.get_type() == Variant::NODE_PATH) { + Node *tonode = n->get_node(p_value); + NodePath p_path = n->get_path_to(tonode); + ur->add_do_property(n,name,p_path); + } else { + ur->add_do_property(n,name,p_value); + } + ur->add_undo_property(n,name,n->get(name)); diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index a2e94e8855..f43bec1cd3 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -1177,8 +1177,6 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c diffuse_at_point.g=res_light.g*diffuse_at_point.g; diffuse_at_point.b=res_light.b*diffuse_at_point.b; - float ret=1e6; - if (p_bounces>0) { @@ -1220,7 +1218,7 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c #endif - ret=_throw_ray(thread_stack,p_bake_direct,r_point,r_point+rn*p_rest,p_rest,diffuse_at_point,p_att_curve,p_att_pos,p_att_curve_len,p_bounces-1); + _throw_ray(thread_stack,p_bake_direct,r_point,r_point+rn*p_rest,p_rest,diffuse_at_point,p_att_curve,p_att_pos,p_att_curve_len,p_bounces-1); } if (use_specular && (specular_at_point.r>CMP_EPSILON || specular_at_point.g>CMP_EPSILON || specular_at_point.b>CMP_EPSILON)) { diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 57707ffa72..b0e002ba44 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -290,6 +290,7 @@ Dictionary CanvasItemEditor::get_state() const { state["snap_rotation"]=snap_rotation; state["snap_relative"]=snap_relative; state["snap_pixel"]=snap_pixel; + state["skeleton_show_bones"]=skeleton_show_bones; return state; } void CanvasItemEditor::set_state(const Dictionary& p_state){ @@ -351,6 +352,12 @@ void CanvasItemEditor::set_state(const Dictionary& p_state){ int idx = edit_menu->get_popup()->get_item_index(SNAP_USE_PIXEL); edit_menu->get_popup()->set_item_checked(idx,snap_pixel); } + + if (state.has("skeleton_show_bones")) { + skeleton_show_bones=state["skeleton_show_bones"]; + int idx = skeleton_menu->get_item_index(SKELETON_SHOW_BONES); + skeleton_menu->set_item_checked(idx,skeleton_show_bones); + } } @@ -1051,7 +1058,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { EditorPluginList *over_plugin_list = en->get_editor_plugins_over(); if (!over_plugin_list->empty()) { - bool discard = over_plugin_list->forward_input_event(p_event); + bool discard = over_plugin_list->forward_input_event(transform,p_event); if (discard) { accept_event(); return; @@ -2083,76 +2090,90 @@ void CanvasItemEditor::_viewport_draw() { } - int bone_width = EditorSettings::get_singleton()->get("2d_editor/bone_width"); - Color bone_color1 = EditorSettings::get_singleton()->get("2d_editor/bone_color1"); - Color bone_color2 = EditorSettings::get_singleton()->get("2d_editor/bone_color2"); - Color bone_ik_color = EditorSettings::get_singleton()->get("2d_editor/bone_ik_color"); - Color bone_selected_color = EditorSettings::get_singleton()->get("2d_editor/bone_selected_color"); + { - for(Map<ObjectID,BoneList>::Element*E=bone_list.front();E;E=E->next()) { + EditorNode *en = editor; + EditorPluginList *over_plugin_list = en->get_editor_plugins_over(); - E->get().from=Vector2(); - E->get().to=Vector2(); + if (!over_plugin_list->empty()) { - Object *obj = ObjectDB::get_instance(E->get().bone); - if (!obj) - continue; + over_plugin_list->forward_draw_over_canvas(transform,viewport); - Node2D* n2d = obj->cast_to<Node2D>(); - if (!n2d) - continue; + } + } - if (!n2d->get_parent()) - continue; + if (skeleton_show_bones) { + int bone_width = EditorSettings::get_singleton()->get("2d_editor/bone_width"); + Color bone_color1 = EditorSettings::get_singleton()->get("2d_editor/bone_color1"); + Color bone_color2 = EditorSettings::get_singleton()->get("2d_editor/bone_color2"); + Color bone_ik_color = EditorSettings::get_singleton()->get("2d_editor/bone_ik_color"); + Color bone_selected_color = EditorSettings::get_singleton()->get("2d_editor/bone_selected_color"); - CanvasItem *pi = n2d->get_parent_item(); + for(Map<ObjectID,BoneList>::Element*E=bone_list.front();E;E=E->next()) { + E->get().from=Vector2(); + E->get().to=Vector2(); - Node2D* pn2d=n2d->get_parent()->cast_to<Node2D>(); + Object *obj = ObjectDB::get_instance(E->get().bone); + if (!obj) + continue; - if (!pn2d) - continue; + Node2D* n2d = obj->cast_to<Node2D>(); + if (!n2d) + continue; - Vector2 from = transform.xform(pn2d->get_global_pos()); - Vector2 to = transform.xform(n2d->get_global_pos()); + if (!n2d->get_parent()) + continue; - E->get().from=from; - E->get().to=to; + CanvasItem *pi = n2d->get_parent_item(); - Vector2 rel = to-from; - Vector2 relt = rel.tangent().normalized()*bone_width; + Node2D* pn2d=n2d->get_parent()->cast_to<Node2D>(); + if (!pn2d) + continue; - Vector<Vector2> bone_shape; - bone_shape.push_back(from); - bone_shape.push_back(from+rel*0.2+relt); - bone_shape.push_back(to); - bone_shape.push_back(from+rel*0.2-relt); - Vector<Color> colors; - if (pi->has_meta("_edit_ik_")) { + Vector2 from = transform.xform(pn2d->get_global_pos()); + Vector2 to = transform.xform(n2d->get_global_pos()); - colors.push_back(bone_ik_color); - colors.push_back(bone_ik_color); - colors.push_back(bone_ik_color); - colors.push_back(bone_ik_color); - } else { - colors.push_back(bone_color1); - colors.push_back(bone_color2); - colors.push_back(bone_color1); - colors.push_back(bone_color2); - } + E->get().from=from; + E->get().to=to; + Vector2 rel = to-from; + Vector2 relt = rel.tangent().normalized()*bone_width; - VisualServer::get_singleton()->canvas_item_add_primitive(ci,bone_shape,colors,Vector<Vector2>(),RID()); - if (editor_selection->is_selected(pi)) { - for(int i=0;i<bone_shape.size();i++) { - VisualServer::get_singleton()->canvas_item_add_line(ci,bone_shape[i],bone_shape[(i+1)%bone_shape.size()],bone_selected_color,2); + Vector<Vector2> bone_shape; + bone_shape.push_back(from); + bone_shape.push_back(from+rel*0.2+relt); + bone_shape.push_back(to); + bone_shape.push_back(from+rel*0.2-relt); + Vector<Color> colors; + if (pi->has_meta("_edit_ik_")) { + + colors.push_back(bone_ik_color); + colors.push_back(bone_ik_color); + colors.push_back(bone_ik_color); + colors.push_back(bone_ik_color); + } else { + colors.push_back(bone_color1); + colors.push_back(bone_color2); + colors.push_back(bone_color1); + colors.push_back(bone_color2); } - } + + VisualServer::get_singleton()->canvas_item_add_primitive(ci,bone_shape,colors,Vector<Vector2>(),RID()); + + if (editor_selection->is_selected(pi)) { + for(int i=0;i<bone_shape.size();i++) { + + VisualServer::get_singleton()->canvas_item_add_line(ci,bone_shape[i],bone_shape[(i+1)%bone_shape.size()],bone_selected_color,2); + } + } + + } } } @@ -2536,6 +2557,12 @@ void CanvasItemEditor::_popup_callback(int p_op) { ((SnapDialog *)snap_dialog)->set_fields(snap_offset, snap_step, snap_rotation_offset, snap_rotation_step); snap_dialog->popup_centered(Size2(220,160)); } break; + case SKELETON_SHOW_BONES: { + skeleton_show_bones = !skeleton_show_bones; + int idx = skeleton_menu->get_item_index(SKELETON_SHOW_BONES); + skeleton_menu->set_item_checked(idx,skeleton_show_bones); + viewport->update(); + } break; case ZOOM_IN: { if (zoom>MAX_ZOOM) return; @@ -2999,6 +3026,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { continue; n2d->set_meta("_edit_bone_",true); + if (!skeleton_show_bones) + skeleton_menu->activate_item(skeleton_menu->get_item_index(SKELETON_SHOW_BONES)); } viewport->update(); @@ -3017,6 +3046,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { continue; n2d->set_meta("_edit_bone_",Variant()); + if (!skeleton_show_bones) + skeleton_menu->activate_item(skeleton_menu->get_item_index(SKELETON_SHOW_BONES)); } viewport->update(); @@ -3036,6 +3067,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { continue; canvas_item->set_meta("_edit_ik_",true); + if (!skeleton_show_bones) + skeleton_menu->activate_item(skeleton_menu->get_item_index(SKELETON_SHOW_BONES)); } @@ -3055,6 +3088,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { continue; n2d->set_meta("_edit_ik_",Variant()); + if (!skeleton_show_bones) + skeleton_menu->activate_item(skeleton_menu->get_item_index(SKELETON_SHOW_BONES)); } viewport->update(); @@ -3401,15 +3436,17 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p->add_shortcut(ED_SHORTCUT("canvas_item_editor/expand_to_parent", TTR("Expand to Parent"), KEY_MASK_CMD | KEY_P), EXPAND_TO_PARENT); p->add_separator(); p->add_submenu_item(TTR("Skeleton.."),"skeleton"); - PopupMenu *p2 = memnew(PopupMenu); - p->add_child(p2); - p2->set_name("skeleton"); - p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTR("Make Bones"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B ),SKELETON_MAKE_BONES); - p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_bones", TTR("Clear Bones")), SKELETON_CLEAR_BONES); - p2->add_separator(); - p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_set_ik_chain", TTR("Make IK Chain")), SKELETON_SET_IK_CHAIN); - p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_ik_chain", TTR("Clear IK Chain")), SKELETON_CLEAR_IK_CHAIN); - p2->connect("item_pressed", this,"_popup_callback"); + skeleton_menu = memnew(PopupMenu); + p->add_child(skeleton_menu); + skeleton_menu->set_name("skeleton"); + skeleton_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTR("Make Bones"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B ),SKELETON_MAKE_BONES); + skeleton_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_bones", TTR("Clear Bones")), SKELETON_CLEAR_BONES); + skeleton_menu->add_separator(); + skeleton_menu->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_show_bones", TTR("Show Bones")), SKELETON_SHOW_BONES); + skeleton_menu->add_separator(); + skeleton_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_set_ik_chain", TTR("Make IK Chain")), SKELETON_SET_IK_CHAIN); + skeleton_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_ik_chain", TTR("Clear IK Chain")), SKELETON_CLEAR_IK_CHAIN); + skeleton_menu->connect("item_pressed", this,"_popup_callback"); /* @@ -3535,6 +3572,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { snap_show_grid=false; snap_rotation=false; snap_pixel=false; + skeleton_show_bones=true; + skeleton_menu->set_item_checked(skeleton_menu->get_item_index(SKELETON_SHOW_BONES),true); updating_value_dialog=false; box_selecting=false; //zoom=0.5; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h index ea582f6fa7..9f4bc46eb4 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.h +++ b/tools/editor/plugins/canvas_item_editor_plugin.h @@ -124,6 +124,7 @@ class CanvasItemEditor : public VBoxContainer { VIEW_FRAME_TO_SELECTION, SKELETON_MAKE_BONES, SKELETON_CLEAR_BONES, + SKELETON_SHOW_BONES, SKELETON_SET_IK_CHAIN, SKELETON_CLEAR_IK_CHAIN @@ -175,6 +176,7 @@ class CanvasItemEditor : public VBoxContainer { bool snap_rotation; bool snap_relative; bool snap_pixel; + bool skeleton_show_bones; bool box_selecting; Point2 box_selecting_to; bool key_pos; @@ -256,6 +258,7 @@ class CanvasItemEditor : public VBoxContainer { ToolButton *ungroup_button; MenuButton *edit_menu; + PopupMenu *skeleton_menu; MenuButton *view_menu; HBoxContainer *animation_hb; MenuButton *animation_menu; diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.h b/tools/editor/plugins/collision_polygon_2d_editor_plugin.h index 982ba35fe8..431d3651c1 100644 --- a/tools/editor/plugins/collision_polygon_2d_editor_plugin.h +++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.h @@ -95,7 +95,7 @@ class CollisionPolygon2DEditorPlugin : public EditorPlugin { public: - virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } + virtual bool forward_canvas_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } virtual String get_name() const { return "CollisionPolygon2D"; } bool has_main_screen() const { return false; } diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.h b/tools/editor/plugins/collision_shape_2d_editor_plugin.h index 1ee81eda43..a8930dc0f2 100644 --- a/tools/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.h @@ -86,7 +86,7 @@ class CollisionShape2DEditorPlugin : public EditorPlugin { EditorNode* editor; public: - virtual bool forward_input_event(const InputEvent& p_event) { return collision_shape_2d_editor->forward_input_event(p_event); } + virtual bool forward_canvas_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) { return collision_shape_2d_editor->forward_input_event(p_event); } virtual String get_name() const { return "CollisionShape2D"; } bool has_main_screen() const { return false; } diff --git a/tools/editor/plugins/light_occluder_2d_editor_plugin.h b/tools/editor/plugins/light_occluder_2d_editor_plugin.h index b570fff506..0176eb87dd 100644 --- a/tools/editor/plugins/light_occluder_2d_editor_plugin.h +++ b/tools/editor/plugins/light_occluder_2d_editor_plugin.h @@ -99,7 +99,7 @@ class LightOccluder2DEditorPlugin : public EditorPlugin { public: - virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } + virtual bool forward_canvas_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } virtual String get_name() const { return "LightOccluder2D"; } bool has_main_screen() const { return false; } diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.h b/tools/editor/plugins/navigation_polygon_editor_plugin.h index 503b4c2662..defdebbec2 100644 --- a/tools/editor/plugins/navigation_polygon_editor_plugin.h +++ b/tools/editor/plugins/navigation_polygon_editor_plugin.h @@ -101,7 +101,7 @@ class NavigationPolygonEditorPlugin : public EditorPlugin { public: - virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } + virtual bool forward_canvas_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } virtual String get_name() const { return "NavigationPolygonInstance"; } bool has_main_screen() const { return false; } diff --git a/tools/editor/plugins/path_2d_editor_plugin.h b/tools/editor/plugins/path_2d_editor_plugin.h index 973c17464e..acbc481e09 100644 --- a/tools/editor/plugins/path_2d_editor_plugin.h +++ b/tools/editor/plugins/path_2d_editor_plugin.h @@ -108,7 +108,7 @@ class Path2DEditorPlugin : public EditorPlugin { public: - virtual bool forward_input_event(const InputEvent& p_event) { return path2d_editor->forward_input_event(p_event); } + virtual bool forward_canvas_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) { return path2d_editor->forward_input_event(p_event); } virtual String get_name() const { return "Path2D"; } bool has_main_screen() const { return false; } diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.h b/tools/editor/plugins/polygon_2d_editor_plugin.h index d8b951ec44..33bae94340 100644 --- a/tools/editor/plugins/polygon_2d_editor_plugin.h +++ b/tools/editor/plugins/polygon_2d_editor_plugin.h @@ -151,7 +151,7 @@ class Polygon2DEditorPlugin : public EditorPlugin { public: - virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } + virtual bool forward_canvas_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } virtual String get_name() const { return "Polygon2D"; } bool has_main_screen() const { return false; } diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index fdb7856b83..3cd6d8336a 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -43,6 +43,17 @@ /*** SCRIPT EDITOR ****/ + +void ScriptEditorBase::_bind_methods() { + + ADD_SIGNAL(MethodInfo("name_changed")); + ADD_SIGNAL(MethodInfo("request_help_search",PropertyInfo(Variant::STRING,"topic"))); + ADD_SIGNAL(MethodInfo("request_open_script_at_line",PropertyInfo(Variant::OBJECT,"script"),PropertyInfo(Variant::INT,"line"))); + ADD_SIGNAL(MethodInfo("request_save_history")); + ADD_SIGNAL(MethodInfo("go_to_help",PropertyInfo(Variant::STRING,"what"))); + +} + static bool _can_open_in_editor(Script* p_script) { String path = p_script->get_path(); @@ -346,6 +357,34 @@ void ScriptEditor::_update_history_arrows() { script_forward->set_disabled( history_pos>=history.size()-1 ); } +void ScriptEditor::_save_history() { + + + if (history_pos>=0 && history_pos<history.size() && history[history_pos].control==tab_container->get_current_tab_control()) { + + Node *n = tab_container->get_current_tab_control(); + + if (n->cast_to<ScriptEditorBase>()) { + + history[history_pos].state=n->cast_to<ScriptEditorBase>()->get_edit_state(); + } + if (n->cast_to<EditorHelp>()) { + + history[history_pos].state=n->cast_to<EditorHelp>()->get_scroll(); + } + } + + history.resize(history_pos+1); + ScriptHistory sh; + sh.control=tab_container->get_current_tab_control(); + sh.state=Variant(); + + history.push_back(sh); + history_pos++; + + _update_history_arrows(); +} + void ScriptEditor::_go_to_tab(int p_idx) { @@ -480,6 +519,33 @@ void ScriptEditor::_close_docs_tab() { } +void ScriptEditor::_close_all_tabs() { + + int child_count = tab_container->get_child_count(); + for (int i = child_count-1; i>=0; i--) { + + tab_container->set_current_tab(i); + ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>(); + + if (se) { + + // Maybe there are unsaved changes + if (se->is_unsaved()) { + _ask_close_current_unsaved_tab(se); + continue; + } + + } + + _close_current_tab(); + } + +} + +void ScriptEditor::_ask_close_current_unsaved_tab(ScriptEditorBase *current) { + erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\""); + erase_tab_confirm->popup_centered_minsize(); +} void ScriptEditor::_resave_scripts(const String& p_str) { @@ -689,29 +755,10 @@ void ScriptEditor::_menu_option(int p_option) { } break; case FILE_SAVE_ALL: { - if (!_test_script_times_on_disk()) + if (_test_script_times_on_disk()) return; save_all_scripts(); - -#if 0 - for(int i=0;i<tab_container->get_child_count();i++) { - - ScriptTextEditor *se = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); - if (!se) - continue; - - - Ref<Script> script = se->get_edited_script(); - - if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) - continue; //internal script, who cares - - - editor->save_resource( script ); - } - -#endif } break; case FILE_IMPORT_THEME: { file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); @@ -831,8 +878,7 @@ void ScriptEditor::_menu_option(int p_option) { case FILE_CLOSE: { if (current->is_unsaved()) { - erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\""); - erase_tab_confirm->popup_centered_minsize(); + _ask_close_current_unsaved_tab(current); } else { _close_current_tab(); } @@ -840,6 +886,9 @@ void ScriptEditor::_menu_option(int p_option) { case CLOSE_DOCS: { _close_docs_tab(); } break; + case CLOSE_ALL: { + _close_all_tabs(); + } break; case DEBUG_NEXT: { if (debugger) @@ -913,6 +962,9 @@ void ScriptEditor::_menu_option(int p_option) { case CLOSE_DOCS: { _close_docs_tab(); } break; + case CLOSE_ALL: { + _close_all_tabs(); + } break; } @@ -1291,9 +1343,8 @@ struct _ScriptEditorItemData { void ScriptEditor::_update_script_colors() { - bool enabled = EditorSettings::get_singleton()->get("text_editor/script_temperature_enabled"); - if (!enabled) - return; + bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/script_temperature_enabled"); + bool highlight_current = EditorSettings::get_singleton()->get("text_editor/highlight_current_script"); int hist_size = EditorSettings::get_singleton()->get("text_editor/script_temperature_history_size"); Color hot_color=EditorSettings::get_singleton()->get("text_editor/script_temperature_hot_color"); @@ -1307,20 +1358,27 @@ void ScriptEditor::_update_script_colors() { continue; script_list->set_item_custom_bg_color(i,Color(0,0,0,0)); - if (!n->has_meta("__editor_pass")) { - continue; - } - int pass=n->get_meta("__editor_pass"); - int h = edit_pass - pass; - if (h>hist_size) { - continue; - } - int non_zero_hist_size = ( hist_size == 0 ) ? 1 : hist_size; - float v = Math::ease((edit_pass-pass)/float(non_zero_hist_size),0.4); + bool current = tab_container->get_current_tab() == c; + if (current && highlight_current) { + script_list->set_item_custom_bg_color(i, EditorSettings::get_singleton()->get("text_editor/current_script_background_color")); + + } else if (script_temperature_enabled) { + + if (!n->has_meta("__editor_pass")) { + continue; + } + int pass=n->get_meta("__editor_pass"); + int h = edit_pass - pass; + if (h>hist_size) { + continue; + } + int non_zero_hist_size = ( hist_size == 0 ) ? 1 : hist_size; + float v = Math::ease((edit_pass-pass)/float(non_zero_hist_size),0.4); - script_list->set_item_custom_bg_color(i,hot_color.linear_interpolate(cold_color,v)); + script_list->set_item_custom_bg_color(i,hot_color.linear_interpolate(cold_color,v)); + } } } @@ -1476,6 +1534,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) { } ERR_FAIL_COND(!se); tab_container->add_child(se); + se->set_edited_script(p_script); se->set_tooltip_request_func("_get_debug_tooltip",this); if (se->get_edit_menu()) { @@ -1497,6 +1556,11 @@ void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) { _save_layout(); se->connect("name_changed",this,"_update_script_names"); se->connect("request_help_search",this,"_help_search"); + se->connect("request_open_script_at_line",this,"_goto_script_line"); + se->connect("go_to_help",this,"_help_class_goto"); + se->connect("request_save_history",this,"_save_history"); + + //test for modification, maybe the script was not edited but was loaded @@ -1653,6 +1717,7 @@ void ScriptEditor::_editor_settings_changed() { se->update_settings(); } + _update_script_colors(); ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/auto_reload_and_parse_scripts_on_save",true)); @@ -1802,7 +1867,6 @@ void ScriptEditor::_help_class_open(const String& p_class) { void ScriptEditor::_help_class_goto(const String& p_desc) { - String cname=p_desc.get_slice(":",1); for(int i=0;i<tab_container->get_child_count();i++) { @@ -1972,6 +2036,7 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_menu_option",&ScriptEditor::_menu_option); ObjectTypeDB::bind_method("_close_current_tab",&ScriptEditor::_close_current_tab); ObjectTypeDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab); + ObjectTypeDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs); ObjectTypeDB::bind_method("_editor_play",&ScriptEditor::_editor_play); ObjectTypeDB::bind_method("_editor_pause",&ScriptEditor::_editor_pause); ObjectTypeDB::bind_method("_editor_stop",&ScriptEditor::_editor_stop); @@ -1982,6 +2047,8 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_goto_script_line",&ScriptEditor::_goto_script_line); ObjectTypeDB::bind_method("_goto_script_line2",&ScriptEditor::_goto_script_line2); ObjectTypeDB::bind_method("_help_search",&ScriptEditor::_help_search); + ObjectTypeDB::bind_method("_save_history",&ScriptEditor::_save_history); + ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); @@ -2052,8 +2119,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reload_script_soft", TTR("Soft Reload Script"), KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_R), FILE_TOOL_RELOAD_SOFT); file_menu->get_popup()->add_separator(); - file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_previous", TTR("History Prev"), KEY_MASK_CTRL|KEY_MASK_ALT|KEY_LEFT), WINDOW_PREV); - file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_next", TTR("History Next"), KEY_MASK_CTRL|KEY_MASK_ALT|KEY_RIGHT), WINDOW_NEXT); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_previous", TTR("History Prev"), KEY_MASK_ALT|KEY_LEFT), WINDOW_PREV); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_next", TTR("History Next"), KEY_MASK_ALT|KEY_RIGHT), WINDOW_NEXT); file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/import_theme", TTR("Import Theme")), FILE_IMPORT_THEME); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reload_theme", TTR("Reload Theme")), FILE_RELOAD_THEME); @@ -2062,6 +2129,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { 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_all", TTR("Close All")), CLOSE_ALL); file_menu->get_popup()->connect("item_pressed", this,"_menu_option"); @@ -2356,9 +2424,11 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { EDITOR_DEF("external_editor/use_external_editor",false); EDITOR_DEF("external_editor/exec_path",""); EDITOR_DEF("text_editor/script_temperature_enabled",true); + EDITOR_DEF("text_editor/highlight_current_script", true); EDITOR_DEF("text_editor/script_temperature_history_size",15); EDITOR_DEF("text_editor/script_temperature_hot_color",Color(1,0,0,0.3)); EDITOR_DEF("text_editor/script_temperature_cold_color",Color(0,0,1,0.3)); + EDITOR_DEF("text_editor/current_script_background_color",Color(0.81,0.81,0.14,0.63)); EDITOR_DEF("text_editor/group_help_pages",true); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"external_editor/exec_path",PROPERTY_HINT_GLOBAL_FILE)); EDITOR_DEF("external_editor/exec_flags",""); diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index 1a23ffed72..10f3bce14e 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -78,7 +78,8 @@ class ScriptEditorDebugger; class ScriptEditorBase : public Control { OBJ_TYPE( ScriptEditorBase, Control ); - +protected: + static void _bind_methods(); public: virtual void apply_code()=0; @@ -133,6 +134,7 @@ class ScriptEditor : public VBoxContainer { FILE_SAVE_THEME_AS, FILE_CLOSE, CLOSE_DOCS, + CLOSE_ALL, FILE_TOOL_RELOAD, FILE_TOOL_RELOAD_SOFT, DEBUG_NEXT, @@ -221,6 +223,9 @@ class ScriptEditor : public VBoxContainer { void _close_current_tab(); void _close_docs_tab(); + void _close_all_tabs(); + + void _ask_close_current_unsaved_tab(ScriptEditorBase *current); bool grab_focus_block; @@ -278,6 +283,7 @@ class ScriptEditor : public VBoxContainer { void _help_class_open(const String& p_class); void _help_class_goto(const String& p_desc); void _update_history_arrows(); + void _save_history(); void _go_to_tab(int p_idx); void _update_history_pos(int p_new_pos); void _update_script_colors(); diff --git a/tools/editor/plugins/script_text_editor.cpp b/tools/editor/plugins/script_text_editor.cpp index 57cf8cbea3..2f807eaa19 100644 --- a/tools/editor/plugins/script_text_editor.cpp +++ b/tools/editor/plugins/script_text_editor.cpp @@ -30,6 +30,7 @@ #include "tools/editor/editor_settings.h" #include "os/keyboard.h" #include "tools/editor/script_editor_debugger.h" +#include "tools/editor/editor_node.h" Vector<String> ScriptTextEditor::get_functions() { @@ -497,6 +498,7 @@ void ScriptTextEditor::_code_complete_scripts(void* p_ud,const String& p_code, L void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>* r_options) { + if (color_panel->is_visible()) return; Node *base = get_tree()->get_edited_scene_root(); if (base) { base = _find_node_for_script(base,base,script); @@ -525,6 +527,74 @@ static void swap_lines(TextEdit *tx, int line1, int line2) tx->cursor_set_line(line2); } +void ScriptTextEditor::_lookup_symbol(const String& p_symbol,int p_row, int p_column) { + + Node *base = get_tree()->get_edited_scene_root(); + if (base) { + base = _find_node_for_script(base,base,script); + } + + + ScriptLanguage::LookupResult result; + if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(),p_symbol,script->get_path().get_base_dir(),base,result)==OK) { + + _goto_line(p_row); + + switch(result.type) { + case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: { + + if (result.script.is_valid()) { + emit_signal("request_open_script_at_line",result.script,result.location-1); + } else { + emit_signal("request_save_history"); + _goto_line(result.location-1); + } + } break; + case ScriptLanguage::LookupResult::RESULT_CLASS: { + emit_signal("go_to_help","class_name:"+result.class_name); + } break; + case ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT: { + + StringName cname = result.class_name; + bool success; + while(true) { + ObjectTypeDB::get_integer_constant(cname,result.class_member,&success); + if (success) { + result.class_name=cname; + cname=ObjectTypeDB::type_inherits_from(cname); + } else { + break; + } + } + + + emit_signal("go_to_help","class_constant:"+result.class_name+":"+result.class_member); + + } break; + case ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY: { + emit_signal("go_to_help","class_property:"+result.class_name+":"+result.class_member); + + } break; + case ScriptLanguage::LookupResult::RESULT_CLASS_METHOD: { + + StringName cname = result.class_name; + + while(true) { + if (ObjectTypeDB::has_method(cname,result.class_member)) { + result.class_name=cname; + cname=ObjectTypeDB::type_inherits_from(cname); + } else { + break; + } + } + + emit_signal("go_to_help","class_method:"+result.class_name+":"+result.class_member); + + } break; + } + + } +} void ScriptTextEditor::_edit_option(int p_op) { @@ -813,6 +883,9 @@ void ScriptTextEditor::_edit_option(int p_op) { case EDIT_TRIM_TRAILING_WHITESAPCE: { trim_trailing_whitespace(); } break; + case EDIT_PICK_COLOR: { + color_panel->popup(); + } break; case SEARCH_FIND: { @@ -919,9 +992,15 @@ void ScriptTextEditor::_bind_methods() { ObjectTypeDB::bind_method("_breakpoint_toggled",&ScriptTextEditor::_breakpoint_toggled); ObjectTypeDB::bind_method("_edit_option",&ScriptTextEditor::_edit_option); ObjectTypeDB::bind_method("_goto_line",&ScriptTextEditor::_goto_line); + ObjectTypeDB::bind_method("_lookup_symbol",&ScriptTextEditor::_lookup_symbol); + ObjectTypeDB::bind_method("_text_edit_input_event", &ScriptTextEditor::_text_edit_input_event); + ObjectTypeDB::bind_method("_color_changed", &ScriptTextEditor::_color_changed); + + + ObjectTypeDB::bind_method("get_drag_data_fw",&ScriptTextEditor::get_drag_data_fw); + ObjectTypeDB::bind_method("can_drop_data_fw",&ScriptTextEditor::can_drop_data_fw); + ObjectTypeDB::bind_method("drop_data_fw",&ScriptTextEditor::drop_data_fw); - ADD_SIGNAL(MethodInfo("name_changed")); - ADD_SIGNAL(MethodInfo("request_help_search",PropertyInfo(Variant::STRING,"topic"))); } Control *ScriptTextEditor::get_edit_menu() { @@ -957,6 +1036,234 @@ void ScriptTextEditor::set_debugger_active(bool p_active) { } + +Variant ScriptTextEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) { + + return Variant(); +} + +bool ScriptTextEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{ + + Dictionary d = p_data; + if (d.has("type") && + ( + + String(d["type"])=="resource" || + String(d["type"])=="files" || + String(d["type"])=="nodes" + ) ) { + + + return true; + } + + + return false; + +} + +#ifdef TOOLS_ENABLED + +static Node* _find_script_node(Node* p_edited_scene,Node* p_current_node,const Ref<Script> &script) { + + if (p_edited_scene!=p_current_node && p_current_node->get_owner()!=p_edited_scene) + return NULL; + + Ref<Script> scr = p_current_node->get_script(); + + if (scr.is_valid() && scr==script) + return p_current_node; + + for(int i=0;i<p_current_node->get_child_count();i++) { + Node *n = _find_script_node(p_edited_scene,p_current_node->get_child(i),script); + if (n) + return n; + } + + return NULL; +} + +#else + +static Node* _find_script_node(Node* p_edited_scene,Node* p_current_node,const Ref<Script> &script) { + + return NULL; +} +#endif + + + + +void ScriptTextEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){ + + Dictionary d = p_data; + + if (d.has("type") && String(d["type"])=="resource") { + + Ref<Resource> res = d["resource"]; + if (!res.is_valid()) { + return; + } + + if (res->get_path().is_resource_file()) { + EditorNode::get_singleton()->show_warning("Only resources from filesystem can be dropped."); + return; + } + + code_editor->get_text_edit()->insert_text_at_cursor(res->get_path()); + + } + + if (d.has("type") && String(d["type"])=="files") { + + + Array files = d["files"]; + + String text_to_drop; + for(int i=0;i<files.size();i++) { + + if (i>0) + text_to_drop+=","; + text_to_drop+="\""+String(files[i]).c_escape()+"\""; + + } + + code_editor->get_text_edit()->insert_text_at_cursor(text_to_drop); + + } + + if (d.has("type") && String(d["type"])=="nodes") { + + Node* sn = _find_script_node(get_tree()->get_edited_scene_root(),get_tree()->get_edited_scene_root(),script); + + + if (!sn) { + EditorNode::get_singleton()->show_warning("Can't drop nodes because script '"+get_name()+"' is not used in this scene."); + return; + } + + + Array nodes = d["nodes"]; + String text_to_drop; + for(int i=0;i<nodes.size();i++) { + + if (i>0) + text_to_drop+=","; + + NodePath np = nodes[i]; + Node *node = get_node(np); + if (!node) { + continue; + } + + + + String path = sn->get_path_to(node); + text_to_drop+="\""+path.c_escape()+"\""; + + + } + + code_editor->get_text_edit()->insert_text_at_cursor(text_to_drop); + + + } + + + +} + +void ScriptTextEditor::_text_edit_input_event(const InputEvent& ev) { + if (ev.type == InputEvent::MOUSE_BUTTON) { + InputEventMouseButton mb = ev.mouse_button; + if (mb.button_index == BUTTON_RIGHT && !mb.pressed) { + + int col, row; + TextEdit* tx = code_editor->get_text_edit(); + tx->_get_mouse_pos(Point2i(mb.global_x, mb.global_y)-tx->get_global_pos(), row, col); + Vector2 mpos = Vector2(mb.global_x, mb.global_y)-tx->get_global_pos(); + bool have_selection = (tx->get_selection_text().length() > 0); + bool have_color = (tx->get_word_at_pos(mpos) == "Color"); + if (have_color) { + + String line = tx->get_line(row); + color_line = row; + int begin = 0; + int end = 0; + bool valid = false; + for (int i = col; i < line.length(); i++) { + if (line[i] == '(') { + begin = i; + continue; + } + else if (line[i] == ')') { + end = i+1; + valid = true; + break; + } + } + if (valid) { + color_args = line.substr(begin, end-begin); + String stripped = color_args.replace(" ", "").replace("(", "").replace(")", ""); + Vector<float> color = stripped.split_floats(","); + if (color.size() > 2) { + float alpha = color.size() > 3 ? color[3] : 1.0f; + color_picker->set_color(Color(color[0], color[1], color[2], alpha)); + } + color_panel->set_pos(get_global_transform().xform(get_local_mouse_pos())); + Size2 ms = Size2(300, color_picker->get_combined_minimum_size().height+10); + color_panel->set_size(ms); + } else { + have_color = false; + } + } + _make_context_menu(have_selection, have_color); + } + } +} + +void ScriptTextEditor::_color_changed(const Color& p_color) { + String new_args; + if (p_color.a == 1.0f) { + new_args = String("("+rtos(p_color.r)+", "+rtos(p_color.g)+", "+rtos(p_color.b)+")"); + } else { + new_args = String("("+rtos(p_color.r)+", "+rtos(p_color.g)+", "+rtos(p_color.b)+", "+rtos(p_color.a)+")"); + } + + String line = code_editor->get_text_edit()->get_line(color_line); + String new_line = line.replace(color_args, new_args); + color_args = new_args; + code_editor->get_text_edit()->set_line(color_line, new_line); +} + +void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { + + context_menu->clear(); + if (p_selection) { + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/copy")); + } + + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/paste")); + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo")); + + if (p_selection) { + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment")); + } + if (p_color) { + context_menu->add_separator(); + context_menu->add_item(TTR("Pick Color"), EDIT_PICK_COLOR); + } + context_menu->set_pos(get_global_transform().xform(get_local_mouse_pos())); + context_menu->set_size(Vector2(1, 1)); + context_menu->popup(); +} + ScriptTextEditor::ScriptTextEditor() { code_editor = memnew( CodeTextEditor ); @@ -966,6 +1273,8 @@ ScriptTextEditor::ScriptTextEditor() { code_editor->connect("load_theme_settings",this,"_load_theme_settings"); code_editor->set_code_complete_func(_code_complete_scripts,this); code_editor->get_text_edit()->connect("breakpoint_toggled", this, "_breakpoint_toggled"); + code_editor->get_text_edit()->connect("symbol_lookup", this, "_lookup_symbol"); + code_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); code_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); @@ -982,6 +1291,21 @@ ScriptTextEditor::ScriptTextEditor() { EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"), EditorSettings::get_singleton()->get("text_editor/callhint_tooltip_offset")); + code_editor->get_text_edit()->set_select_identifiers_on_hover(true); + code_editor->get_text_edit()->set_context_menu_enabled(false); + code_editor->get_text_edit()->connect("input_event", this, "_text_edit_input_event"); + + context_menu = memnew(PopupMenu); + add_child(context_menu); + context_menu->connect("item_pressed", this, "_edit_option"); + + color_panel = memnew(PopupPanel); + add_child(color_panel); + color_picker = memnew(ColorPicker); + color_panel->add_child(color_picker); + color_panel->set_child_rect(color_picker); + color_picker->connect("color_changed", this, "_color_changed"); + edit_hb = memnew (HBoxContainer); edit_menu = memnew( MenuButton ); @@ -1039,6 +1363,9 @@ ScriptTextEditor::ScriptTextEditor() { goto_line_dialog = memnew(GotoLineDialog); add_child(goto_line_dialog); + + + code_editor->get_text_edit()->set_drag_forwarding(this); } static ScriptEditorBase * create_editor(const Ref<Script>& p_script) { diff --git a/tools/editor/plugins/script_text_editor.h b/tools/editor/plugins/script_text_editor.h index 247fd97e81..ceef50f0bc 100644 --- a/tools/editor/plugins/script_text_editor.h +++ b/tools/editor/plugins/script_text_editor.h @@ -30,6 +30,7 @@ #define SCRIPT_TEXT_EDITOR_H #include "script_editor_plugin.h" +#include "scene/gui/color_picker.h" class ScriptTextEditor : public ScriptEditorBase { @@ -47,10 +48,16 @@ class ScriptTextEditor : public ScriptEditorBase { MenuButton *edit_menu; MenuButton *search_menu; + PopupMenu *context_menu; GotoLineDialog *goto_line_dialog; ScriptEditorQuickOpen *quick_open; + PopupPanel *color_panel; + ColorPicker *color_picker; + int color_line; + String color_args; + enum { EDIT_UNDO, EDIT_REDO, @@ -67,6 +74,7 @@ class ScriptTextEditor : public ScriptEditorBase { EDIT_INDENT_RIGHT, EDIT_INDENT_LEFT, EDIT_CLONE_DOWN, + EDIT_PICK_COLOR, SEARCH_FIND, SEARCH_FIND_NEXT, SEARCH_FIND_PREV, @@ -96,8 +104,17 @@ protected: static void _bind_methods(); void _edit_option(int p_op); + void _make_context_menu(bool p_selection, bool p_color); + void _text_edit_input_event(const InputEvent& ev); + void _color_changed(const Color& p_color); void _goto_line(int p_line) { goto_line(p_line); } + void _lookup_symbol(const String& p_symbol,int p_row, int p_column); + + Variant get_drag_data_fw(const Point2& p_point,Control* p_from); + bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const; + void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from); + public: virtual void apply_code(); diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp index 815da48e96..3ab906f84e 100644 --- a/tools/editor/plugins/shader_graph_editor_plugin.cpp +++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp @@ -901,6 +901,7 @@ void ShaderGraphView::_variant_edited() { case Variant::COLOR: v2=Color(); break; + default: {} } UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Default Value")); @@ -1321,6 +1322,7 @@ void ShaderGraphView::_default_changed(int p_id, Node *p_button, int p_param, in h=PROPERTY_HINT_COLOR_NO_ALPHA; v=Color(); break; + default: {} } ped_popup->edit(NULL,"",vt,v,h,p_hint); @@ -1347,6 +1349,8 @@ ToolButton *ShaderGraphView::make_label(String text, Variant::Type v_type) { break; case Variant::COLOR: l->set_icon(ped_popup->get_icon("Color", "EditorIcons")); + break; + default: {} } return l; } @@ -1372,7 +1376,7 @@ ToolButton *ShaderGraphView::make_editor(String text,GraphNode* gn,int p_id,int case Variant::TRANSFORM: edit->set_icon(ped_popup->get_icon("Matrix", "EditorIcons")); break; - case Variant::COLOR: + case Variant::COLOR: { Image icon_color = Image(15,15,false,Image::FORMAT_RGB); Color c = graph->default_get_value(type,p_id,param); for (int x=1;x<14;x++) @@ -1382,7 +1386,8 @@ ToolButton *ShaderGraphView::make_editor(String text,GraphNode* gn,int p_id,int t.instance(); t->create_from_image(icon_color); edit->set_icon(t); - break; + } break; + default: {} } return edit; } @@ -2417,6 +2422,7 @@ void ShaderGraphView::_create_node(int p_id) { colors.push_back("Color"); colors.push_back("LightColor"); colors.push_back("Light"); + colors.push_back("ShadowColor"); colors.push_back("Diffuse"); colors.push_back("Specular"); colors.push_back("Emmision"); @@ -2429,6 +2435,7 @@ void ShaderGraphView::_create_node(int p_id) { reals.push_back("ShadeParam"); reals.push_back("SpecularExp"); reals.push_back("LightAlpha"); + reals.push_back("ShadowAlpha"); reals.push_back("PointSize"); reals.push_back("Discard"); diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 95106d2c81..6dcc71422a 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1978,6 +1978,11 @@ void SpatialEditorViewport::_menu_option(int p_option) { _update_name(); } break; + case VIEW_CENTER_TO_ORIGIN: { + + cursor.pos = Vector3(0,0,0); + + } break; case VIEW_CENTER_TO_SELECTION: { focus_selection(); @@ -2391,6 +2396,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_GIZMOS),true); view_menu->get_popup()->add_separator(); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_origin"), VIEW_CENTER_TO_ORIGIN); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_selection_with_view"), VIEW_ALIGN_SELECTION_WITH_VIEW); view_menu->get_popup()->connect("item_pressed",this,"_menu_option"); @@ -3151,6 +3157,8 @@ void SpatialEditor::_init_indicators() { Vector<Color> origin_colors; Vector<Vector3> origin_points; + Color grid_color = EditorSettings::get_singleton()->get("3d_editor/grid_color"); + for(int i=0;i<3;i++) { Vector3 axis; axis[i]=1; @@ -3168,10 +3176,10 @@ void SpatialEditor::_init_indicators() { for(int j=-ORIGIN_GRID_SIZE;j<=ORIGIN_GRID_SIZE;j++) { - grid_colors[i].push_back(Color(axis.x,axis.y,axis.z,0.2)); - grid_colors[i].push_back(Color(axis.x,axis.y,axis.z,0.2)); - grid_colors[i].push_back(Color(axis.x,axis.y,axis.z,0.2)); - grid_colors[i].push_back(Color(axis.x,axis.y,axis.z,0.2)); + grid_colors[i].push_back(grid_color); + grid_colors[i].push_back(grid_color); + grid_colors[i].push_back(grid_color); + grid_colors[i].push_back(grid_color); grid_points[i].push_back(axis_n1*ORIGIN_GRID_SIZE+axis_n2*j); grid_points[i].push_back(-axis_n1*ORIGIN_GRID_SIZE+axis_n2*j); grid_points[i].push_back(axis_n2*ORIGIN_GRID_SIZE+axis_n1*j); @@ -3467,6 +3475,8 @@ void SpatialEditor::_unhandled_key_input(InputEvent p_event) { if (!is_visible() || get_viewport()->gui_has_modal_stack()) return; +#if 0 +//i don't remember this being used, why was it here? { EditorNode *en = editor; @@ -3478,6 +3488,7 @@ void SpatialEditor::_unhandled_key_input(InputEvent p_event) { } } +#endif switch(p_event.type) { @@ -3853,6 +3864,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { ED_SHORTCUT("spatial_editor/switch_perspective_orthogonal", TTR("Switch Perspective/Orthogonal view"), KEY_KP_5); ED_SHORTCUT("spatial_editor/snap", TTR("Snap"), KEY_S); ED_SHORTCUT("spatial_editor/insert_anim_key", TTR("Insert Animation Key"), KEY_K); + ED_SHORTCUT("spatial_editor/focus_origin", TTR("Focus Origin"), KEY_O); ED_SHORTCUT("spatial_editor/focus_selection", TTR("Focus Selection"), KEY_F); ED_SHORTCUT("spatial_editor/align_selection_with_view", TTR("Align Selection With View"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_F); diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h index 975092a01d..89587526ee 100644 --- a/tools/editor/plugins/spatial_editor_plugin.h +++ b/tools/editor/plugins/spatial_editor_plugin.h @@ -76,6 +76,7 @@ friend class SpatialEditor; VIEW_RIGHT, VIEW_FRONT, VIEW_REAR, + VIEW_CENTER_TO_ORIGIN, VIEW_CENTER_TO_SELECTION, VIEW_ALIGN_SELECTION_WITH_VIEW, VIEW_PERSPECTIVE, diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 5db331ba45..84568aa8c0 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -668,7 +668,7 @@ ThemeEditor::ThemeEditor() { theme_menu = memnew( MenuButton ); - theme_menu->set_text("Theme"); + theme_menu->set_text(TTR("Theme")); theme_menu->get_popup()->add_item(TTR("Add Item"),POPUP_ADD); theme_menu->get_popup()->add_item(TTR("Add Class Items"),POPUP_CLASS_ADD); theme_menu->get_popup()->add_item(TTR("Remove Item"),POPUP_REMOVE); diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 822d9e6c87..43fe7d7ea9 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -289,15 +289,16 @@ void TileMapEditor::_pick_tile(const Point2& p_pos) { canvas_item_editor->update(); } -DVector<Vector2> TileMapEditor::_bucket_fill(const Point2i& p_start) { +DVector<Vector2> TileMapEditor::_bucket_fill(const Point2i& p_start, bool erase) { - if (node->get_cell(p_start.x, p_start.y) != TileMap::INVALID_CELL) - return DVector<Vector2>(); + int prev_id = node->get_cell(p_start.x, p_start.y); + int id = TileMap::INVALID_CELL; + if (!erase) { + id = get_selected_tile(); - int id = get_selected_tile(); - - if (id == TileMap::INVALID_CELL) - return DVector<Vector2>(); + if (id == TileMap::INVALID_CELL) + return DVector<Vector2>(); + } Rect2 r = node->get_item_rect(); r.pos = r.pos/node->get_cell_size(); @@ -316,7 +317,7 @@ DVector<Vector2> TileMapEditor::_bucket_fill(const Point2i& p_start) { if (!r.has_point(n)) continue; - if (node->get_cell(n.x, n.y) == TileMap::INVALID_CELL) { + if (node->get_cell(n.x, n.y) == prev_id) { node->set_cellv(n, id, flip_h, flip_v, transpose); @@ -685,6 +686,12 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { } else if (tool==TOOL_BUCKET) { + Dictionary pop; + pop["id"] = node->get_cell(over_tile.x, over_tile.y); + pop["flip_h"] = node->is_cell_x_flipped(over_tile.x, over_tile.y); + pop["flip_v"] = node->is_cell_y_flipped(over_tile.x, over_tile.y); + pop["transpose"] = node->is_cell_transposed(over_tile.x, over_tile.y); + DVector<Vector2> points = _bucket_fill(over_tile); if (points.size() == 0) @@ -699,7 +706,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { undo_redo->create_action("Bucket Fill"); undo_redo->add_do_method(this, "_fill_points", points, op); - undo_redo->add_undo_method(this, "_erase_points", points); + undo_redo->add_undo_method(this, "_fill_points", points, pop); undo_redo->commit_action(); } @@ -782,6 +789,26 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { tool=TOOL_NONE; return true; + + } else if (tool==TOOL_BUCKET) { + + Dictionary pop; + pop["id"] = node->get_cell(over_tile.x, over_tile.y); + pop["flip_h"] = node->is_cell_x_flipped(over_tile.x, over_tile.y); + pop["flip_v"] = node->is_cell_y_flipped(over_tile.x, over_tile.y); + pop["transpose"] = node->is_cell_transposed(over_tile.x, over_tile.y); + + DVector<Vector2> points = _bucket_fill(over_tile, true); + + if (points.size() == 0) + return false; + + undo_redo->create_action("Bucket Fill"); + + undo_redo->add_do_method(this, "_erase_points", points); + undo_redo->add_undo_method(this, "_fill_points", points, pop); + + undo_redo->commit_action(); } } } @@ -798,7 +825,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { canvas_item_editor->update(); } - int tile_under = node->get_cell(over_tile.x, over_tile.y); + int tile_under = node->get_cell(over_tile.x, over_tile.y); String tile_name = "none"; if (node->get_tileset()->has_tile(tile_under)) diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h index 666290489b..2f24002770 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.h +++ b/tools/editor/plugins/tile_map_editor_plugin.h @@ -129,7 +129,7 @@ class TileMapEditor : public VBoxContainer { void _pick_tile(const Point2& p_pos); - DVector<Vector2> _bucket_fill(const Point2i& p_start); + DVector<Vector2> _bucket_fill(const Point2i& p_start, bool erase=false); void _fill_points(const DVector<Vector2> p_points, const Dictionary& p_op); void _erase_points(const DVector<Vector2> p_points); @@ -181,7 +181,7 @@ class TileMapEditorPlugin : public EditorPlugin { public: - virtual bool forward_input_event(const InputEvent& p_event) { return tile_map_editor->forward_input_event(p_event); } + virtual bool forward_canvas_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) { return tile_map_editor->forward_input_event(p_event); } virtual String get_name() const { return "TileMap"; } bool has_main_screen() const { return false; } diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index dc1d6ec0f9..1c99982155 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -142,6 +142,7 @@ private: String sp = p.simplify_path(); project_path->set_text(sp); _path_text_changed(p); + get_ok()->call_deferred("grab_focus"); } void _path_selected(const String& p_path) { @@ -150,7 +151,7 @@ private: String sp = p.simplify_path(); project_path->set_text(sp); _path_text_changed(p); - + get_ok()->call_deferred("grab_focus"); } void _browse_path() { @@ -506,7 +507,7 @@ void ProjectManager::_panel_draw(Node *p_hb) { hb->draw_line(Point2(0,hb->get_size().y+1),Point2(hb->get_size().x-10,hb->get_size().y+1),get_color("guide_color","Tree")); if (selected_list.has(hb->get_meta("name"))) { - hb->draw_style_box(get_stylebox("selected","Tree"),Rect2(Point2(),hb->get_size()-Size2(10,0))); + hb->draw_style_box( gui_base->get_stylebox("selected","Tree"),Rect2(Point2(),hb->get_size()-Size2(10,0))); } } @@ -753,7 +754,7 @@ void ProjectManager::_load_recent_projects() { List<PropertyInfo> properties; EditorSettings::get_singleton()->get_property_list(&properties); - Color font_color = get_color("font_color","Tree"); + Color font_color = gui_base->get_color("font_color","Tree"); List<ProjectItem> projects; List<ProjectItem> favorite_projects; @@ -864,6 +865,7 @@ void ProjectManager::_load_recent_projects() { hb->set_meta("favorite",is_favorite); hb->connect("draw",this,"_panel_draw",varray(hb)); hb->connect("input_event",this,"_panel_input",varray(hb)); + hb->add_constant_override("separation",10*EDSCALE); VBoxContainer *favorite_box = memnew( VBoxContainer ); TextureButton *favorite = memnew( TextureButton ); @@ -885,7 +887,7 @@ void ProjectManager::_load_recent_projects() { ec->set_custom_minimum_size(Size2(0,1)); vb->add_child(ec); Label *title = memnew( Label(project_name) ); - title->add_font_override("font",get_font("large","Fonts")); + title->add_font_override("font", gui_base->get_font("large","Fonts")); title->add_color_override("font_color",font_color); vb->add_child(title); Label *fpath = memnew( Label(path) ); @@ -1185,25 +1187,27 @@ ProjectManager::ProjectManager() { { int dpi_mode = EditorSettings::get_singleton()->get("global/hidpi_mode"); if (dpi_mode==0) { - editor_set_hidpi( OS::get_singleton()->get_screen_dpi(0) > 150 ); + editor_set_scale( OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x>2000 ? 2.0 : 1.0 ); + } else if (dpi_mode==1) { + editor_set_scale(0.75); } else if (dpi_mode==2) { - editor_set_hidpi(true); - } else { - editor_set_hidpi(false); + editor_set_scale(1.0); + } else if (dpi_mode==3) { + editor_set_scale(1.5); + } else if (dpi_mode==4) { + editor_set_scale(2.0); } } FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); set_area_as_parent_rect(); + set_theme(create_editor_theme()); gui_base = memnew( Control ); add_child(gui_base); gui_base->set_area_as_parent_rect(); - - set_theme(create_default_theme()); - Ref<Theme> theme = create_editor_theme(); - gui_base->set_theme(theme); + gui_base->set_theme(create_custom_theme()); Panel *panel = memnew( Panel ); gui_base->add_child(panel); @@ -1226,7 +1230,7 @@ ProjectManager::ProjectManager() { CenterContainer *ccl = memnew( CenterContainer ); Label *l = memnew( Label ); l->set_text(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager")); - l->add_font_override("font",get_font("doc","EditorFonts")); + l->add_font_override("font", gui_base->get_font("doc","EditorFonts")); ccl->add_child(l); top_hb->add_child(ccl); top_hb->add_spacer(); @@ -1262,7 +1266,7 @@ ProjectManager::ProjectManager() { search_tree_vb->add_child(search_box); PanelContainer *pc = memnew( PanelContainer); - pc->add_style_override("panel",get_stylebox("bg","Tree")); + pc->add_style_override("panel", gui_base->get_stylebox("bg","Tree")); search_tree_vb->add_child(pc); pc->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 2ea28e26ad..7163836f73 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -214,6 +214,12 @@ void CustomPropertyEditor::_menu_option(int p_which) { } } } break; + case OBJ_MENU_NEW_SCRIPT: { + + if (owner->cast_to<Node>()) + EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(owner->cast_to<Node>()); + + } break; default: { @@ -850,8 +856,10 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty menu->clear(); menu->set_size(Size2(1,1)); - - if (hint_text!="") { + if (p_name=="script/script" && hint_text=="Script" && owner->cast_to<Node>()) { + menu->add_icon_item(get_icon("Script","EditorIcons"),TTR("New Script"),OBJ_MENU_NEW_SCRIPT); + menu->add_separator(); + } else if (hint_text!="") { int idx=0; for(int i=0;i<hint_text.get_slice_count(",");i++) { @@ -3041,7 +3049,7 @@ void PropertyEditor::update_tree() { if (E) { descr=E->get().brief_description; } - class_descr_cache[type]=descr.world_wrap(80); + class_descr_cache[type]=descr.word_wrap(80); } @@ -3134,7 +3142,7 @@ void PropertyEditor::update_tree() { if (E) { for(int i=0;i<E->get().methods.size();i++) { if (E->get().methods[i].name==setter.operator String()) { - descr=E->get().methods[i].description.strip_edges().world_wrap(80); + descr=E->get().methods[i].description.strip_edges().word_wrap(80); } } } @@ -3174,6 +3182,7 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CHECK ); item->set_text(1,TTR("On")); + item->set_tooltip(1, obj->get(p.name) ? "True" : "False"); item->set_checked( 1, obj->get( p.name ) ); if (show_type_icons) item->set_icon( 0, get_icon("Bool","EditorIcons") ); @@ -3820,6 +3829,7 @@ void PropertyEditor::_item_edited() { case Variant::BOOL: { _edit_set(name,item->is_checked(1)); + item->set_tooltip(1, item->is_checked(1) ? "True" : "False"); } break; case Variant::INT: case Variant::REAL: { @@ -4557,7 +4567,7 @@ void SectionedPropertyEditor::update_category_list() { else if ( !(pi.usage&PROPERTY_USAGE_EDITOR) ) continue; - if (pi.name.find(":")!=-1 || pi.name=="script/script") + if (pi.name.find(":")!=-1 || pi.name=="script/script" || pi.name.begins_with("resource/")) continue; int sp = pi.name.find("/"); if (sp!=-1) { diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index 6c6c309d32..3fe332bf87 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -65,6 +65,7 @@ class CustomPropertyEditor : public Popup { OBJ_MENU_COPY=4, OBJ_MENU_PASTE=5, OBJ_MENU_REIMPORT=6, + OBJ_MENU_NEW_SCRIPT=7, TYPE_BASE_ID=100 }; diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 506dfd3889..342e6b98c8 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -227,7 +227,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String>& p_files,Node* editor_data->get_undo_redo().add_do_reference(instanced_scene); editor_data->get_undo_redo().add_undo_method(parent,"remove_child",instanced_scene); - String new_name = parent->validate_child_name(instanced_scene->get_name()); + String new_name = parent->validate_child_name(instanced_scene); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); editor_data->get_undo_redo().add_do_method(sed,"live_debug_instance_node",edited_scene->get_path_to(parent),p_files[i],new_name); editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+new_name)); @@ -257,17 +257,6 @@ bool SceneTreeDock::_cyclical_dependency_exists(const String& p_target_scene_pat } -static String _get_name_num_separator() { - switch(EditorSettings::get_singleton()->get("scenetree_editor/duplicate_node_name_num_separator").operator int()) { - case 0: return ""; - case 1: return " "; - case 2: return "_"; - case 3: return "-"; - } - return " "; -} - - void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option=p_tool; @@ -474,37 +463,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (selection.size()==1) dupsingle=dup; - String name = node->get_name(); - - String nums; - for(int i=name.length()-1;i>=0;i--) { - CharType n=name[i]; - if (n>='0' && n<='9') { - nums=String::chr(name[i])+nums; - } else { - break; - } - } - - int num=nums.to_int(); - if (num<1) - num=1; - else - num++; - - String nnsep = _get_name_num_separator(); - name = name.substr(0,name.length()-nums.length()).strip_edges(); - if ( name.substr(name.length()-nnsep.length(),nnsep.length()) == nnsep) { - name = name.substr(0,name.length()-nnsep.length()); - } - String attempt = (name + nnsep + itos(num)).strip_edges(); - - while(parent->has_node(attempt)) { - num++; - attempt = (name + nnsep + itos(num)).strip_edges(); - } - - dup->set_name(attempt); + dup->set_name(parent->validate_child_name(dup)); editor_data->get_undo_redo().add_do_method(parent,"_add_child_below_node",node, dup); for (List<Node*>::Element *F=owned.front();F;F=F->next()) { @@ -522,8 +481,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); - editor_data->get_undo_redo().add_do_method(sed,"live_debug_duplicate_node",edited_scene->get_path_to(node),attempt); - editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+attempt)); + editor_data->get_undo_redo().add_do_method(sed,"live_debug_duplicate_node",edited_scene->get_path_to(node),dup->get_name()); + editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+dup->get_name())); //parent->add_child(dup); //reselect.push_back(dup); @@ -1109,6 +1068,7 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().create_action(TTR("Reparent Node")); List<Pair<NodePath,NodePath> > path_renames; + Vector<StringName> former_names; int inc=0; @@ -1118,6 +1078,7 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec Node *node = p_nodes[ni]; fill_path_renames(node,new_parent,&path_renames); + former_names.push_back(node->get_name()); List<Node*> owned; node->get_owned_by(node->get_owner(),&owned); @@ -1140,7 +1101,7 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_do_method(new_parent,"move_child",node,p_position_in_parent+inc); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); - String new_name = new_parent->validate_child_name(node->get_name()); + String new_name = new_parent->validate_child_name(node); editor_data->get_undo_redo().add_do_method(sed,"live_debug_reparent_node",edited_scene->get_path_to(node),edited_scene->get_path_to(new_parent),new_name,-1); editor_data->get_undo_redo().add_undo_method(sed,"live_debug_reparent_node",NodePath(String(edited_scene->get_path_to(new_parent))+"/"+new_name),edited_scene->get_path_to(node->get_parent()),node->get_name(),node->get_index()); @@ -1159,6 +1120,7 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_do_method(AnimationPlayerEditor::singleton->get_key_editor(),"set_root",node); editor_data->get_undo_redo().add_undo_method(new_parent,"remove_child",node); + editor_data->get_undo_redo().add_undo_method(node,"set_name",former_names[ni]); inc++; @@ -1360,7 +1322,7 @@ void SceneTreeDock::_create() { editor_data->get_undo_redo().add_undo_method(parent,"remove_child",child); - String new_name = parent->validate_child_name(child->get_type()); + String new_name = parent->validate_child_name(child); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); editor_data->get_undo_redo().add_do_method(sed,"live_debug_create_node",edited_scene->get_path_to(parent),child->get_type(),new_name); editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+new_name)); @@ -1841,6 +1803,12 @@ void SceneTreeDock::_focus_node() { } } +void SceneTreeDock::open_script_dialog(Node* p_for_node) { + + scene_tree->set_selected(p_for_node,false); + _tool_selected(TOOL_SCRIPT); +} + void SceneTreeDock::_bind_methods() { ObjectTypeDB::bind_method(_MD("_tool_selected"),&SceneTreeDock::_tool_selected,DEFVAL(false)); diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h index d92f12c34b..971013a568 100644 --- a/tools/editor/scene_tree_dock.h +++ b/tools/editor/scene_tree_dock.h @@ -175,6 +175,7 @@ public: SceneTreeEditor *get_tree_editor() { return scene_tree; } + void open_script_dialog(Node* p_for_node); SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelection *p_editor_selection,EditorData &p_editor_data); }; diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index e5a97fa26e..53bfe8cc57 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -254,7 +254,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) String config_err = n->get_configuration_warning(); if (config_err==String()) return; - config_err=config_err.world_wrap(80); + config_err=config_err.word_wrap(80); warning->set_text(config_err); warning->popup_centered_minsize(); diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index da42f54095..c8170ca9a3 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -216,6 +216,8 @@ void ScriptEditorDebugger::debug_continue() { ERR_FAIL_COND(connection.is_null()); ERR_FAIL_COND(!connection->is_connected()); + OS::get_singleton()->enable_for_stealing_focus(EditorNode::get_singleton()->get_child_process_id()); + Array msg; msg.push_back("continue"); ppeer->put_var(msg); @@ -1087,6 +1089,9 @@ void ScriptEditorDebugger::start() { stop(); + if (!EditorNode::get_log()->is_visible()) { + EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log()); + } uint16_t port = GLOBAL_DEF("debug/remote_port",6007); perf_history.clear(); diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index 480d33fd0a..84803eb6db 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -422,8 +422,6 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po if (billboard_handle) { t.set_look_at(t.origin,t.origin+p_camera->get_transform().basis.get_axis(2),p_camera->get_transform().basis.get_axis(1)); } - Transform ti=t.affine_inverse(); - float min_d=1e20; int idx=-1; |