diff options
Diffstat (limited to 'tools/editor')
46 files changed, 1639 insertions, 507 deletions
diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index ace6fda696..b8aa5874d1 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -34,6 +34,7 @@ #include "pair.h" #include "scene/gui/separator.h" #include "editor_node.h" +#include "tools/editor/plugins/animation_player_editor_plugin.h" /* Missing to fix: *Set @@ -903,6 +904,23 @@ void AnimationKeyEditor::_menu_track(int p_type) { optimize_dialog->popup_centered(Size2(250,180)); } break; + case TRACK_MENU_CLEAN_UP: { + + cleanup_dialog->popup_centered_minsize(Size2(300,0)); + } break; + case TRACK_MENU_CLEAN_UP_CONFIRM: { + + if (cleanup_all->is_pressed()) { + List<StringName> names; + AnimationPlayerEditor::singleton->get_player()->get_animation_list(&names); + for (List<StringName>::Element *E=names.front();E;E=E->next()) { + _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E->get())); + } + } else { + _cleanup_animation(animation); + + } + } break; case CURVE_SET_LINEAR: { curve_edit->force_transition(1.0); @@ -933,6 +951,57 @@ void AnimationKeyEditor::_menu_track(int p_type) { } +void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) { + + + for(int i=0;i<p_animation->get_track_count();i++) { + + bool prop_exists=false; + Variant::Type valid_type=Variant::NIL; + Object *obj=NULL; + + RES res; + Node *node = root->get_node_and_resource(p_animation->track_get_path(i),res); + + if (res.is_valid()) { + obj=res.ptr(); + } else if (node) { + obj=node; + } + + if (obj && p_animation->track_get_type(i)==Animation::TYPE_VALUE) { + valid_type=obj->get_static_property_type(p_animation->track_get_path(i).get_property(),&prop_exists); + } + + if (!obj && cleanup_tracks->is_pressed()) { + + p_animation->remove_track(i); + i--; + continue; + } + + if (!prop_exists || p_animation->track_get_type(i)!=Animation::TYPE_VALUE || cleanup_keys->is_pressed()==false) + continue; + + for(int j=0;j<p_animation->track_get_key_count(i);j++) { + + Variant v = p_animation->track_get_key_value(i,j); + + if (!Variant::can_convert(v.get_type(),valid_type)) { + p_animation->track_remove_key(i,j); + j--; + } + } + + if (p_animation->track_get_key_count(i)==0 && cleanup_tracks->is_pressed()) { + p_animation->remove_track(i); + i--; + } + } + + undo_redo->clear_history(); + _update_paths(); +} void AnimationKeyEditor::_animation_optimize() { @@ -1042,6 +1111,7 @@ void AnimationKeyEditor::_track_editor_draw() { timecolor = Color::html("ff4a414f"); Color hover_color = Color(1,1,1,0.05); Color select_color = Color(1,1,1,0.1); + Color invalid_path_color = Color(1,0.6,0.4,0.5); Color track_select_color =Color::html("ffbd8e8e"); Ref<Texture> remove_icon = get_icon("Remove","EditorIcons"); @@ -1068,6 +1138,9 @@ void AnimationKeyEditor::_track_editor_draw() { get_icon("KeyCall","EditorIcons") }; + Ref<Texture> invalid_icon = get_icon("KeyInvalid","EditorIcons"); + Ref<Texture> invalid_icon_hover = get_icon("KeyInvalidHover","EditorIcons"); + Ref<Texture> hsize_icon = get_icon("Hsize","EditorIcons"); Ref<Texture> type_hover=get_icon("KeyHover","EditorIcons"); @@ -1254,6 +1327,23 @@ void AnimationKeyEditor::_track_editor_draw() { break; int y = h+i*h+sep; + bool prop_exists=false; + Variant::Type valid_type=Variant::NIL; + Object *obj=NULL; + + RES res; + Node *node = root->get_node_and_resource(animation->track_get_path(idx),res); + + if (res.is_valid()) { + obj=res.ptr(); + } else if (node) { + obj=node; + } + + if (obj && animation->track_get_type(idx)==Animation::TYPE_VALUE) { + valid_type=obj->get_static_property_type(animation->track_get_path(idx).get_property(),&prop_exists); + } + if (/*mouse_over.over!=MouseOver::OVER_NONE &&*/ idx==mouse_over.track) { Color sepc=hover_color; @@ -1274,6 +1364,8 @@ void AnimationKeyEditor::_track_editor_draw() { ncol=track_select_color; te->draw_string(font,Point2(ofs+Point2(type_icon[0]->get_width()+sep,y+font->get_ascent()+(sep/2))).floor(),np,ncol,name_limit-(type_icon[0]->get_width()+sep)-5); + if (!obj) + te->draw_line(ofs+Point2(0,y+h/2),ofs+Point2(name_limit,y+h/2),invalid_path_color); te->draw_line(ofs+Point2(0,y+h),ofs+Point2(size.width,y+h),sepcolor); @@ -1339,6 +1431,8 @@ void AnimationKeyEditor::_track_editor_draw() { int kc=animation->track_get_key_count(idx); bool first=true; + + for(int i=0;i<kc;i++) { @@ -1386,7 +1480,21 @@ void AnimationKeyEditor::_track_editor_draw() { } - te->draw_texture(tex,ofs+Point2(x,y+key_vofs).floor()); + if (prop_exists && !Variant::can_convert(value.get_type(),valid_type)) { + te->draw_texture(invalid_icon,ofs+Point2(x,y+key_vofs).floor()); + } + + if (prop_exists && !Variant::can_convert(value.get_type(),valid_type)) { + if (tex==type_hover) + te->draw_texture(invalid_icon_hover,ofs+Point2(x,y+key_vofs).floor()); + else + te->draw_texture(invalid_icon,ofs+Point2(x,y+key_vofs).floor()); + } else { + + te->draw_texture(tex,ofs+Point2(x,y+key_vofs).floor()); + } + + first=false; } @@ -2555,6 +2663,8 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { String text; text="time: "+rtos(animation->track_get_key_time(idx,mouse_over.over_key))+"\n"; + + switch(animation->track_get_type(idx)) { case Animation::TYPE_TRANSFORM: { @@ -2569,8 +2679,33 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { } break; case Animation::TYPE_VALUE: { - Variant v = animation->track_get_key_value(idx,mouse_over.over_key); - text+="value: "+String(v)+"\n"; + Variant v = animation->track_get_key_value(idx,mouse_over.over_key);; + //text+="value: "+String(v)+"\n"; + + bool prop_exists=false; + Variant::Type valid_type=Variant::NIL; + Object *obj=NULL; + + RES res; + Node *node = root->get_node_and_resource(animation->track_get_path(idx),res); + + if (res.is_valid()) { + obj=res.ptr(); + } else if (node) { + obj=node; + } + + if (obj) { + valid_type=obj->get_static_property_type(animation->track_get_path(idx).get_property(),&prop_exists); + } + + text+="type: "+Variant::get_type_name(v.get_type())+"\n"; + if (prop_exists && !Variant::can_convert(v.get_type(),valid_type)) { + text+="value: "+String(v)+" (Invalid, expected type: "+Variant::get_type_name(valid_type)+")\n"; + } else { + text+="value: "+String(v)+"\n"; + } + } break; case Animation::TYPE_METHOD: { @@ -2593,6 +2728,9 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { } break; } text+="easing: "+rtos(animation->track_get_key_transition(idx,mouse_over.over_key)); + + + track_editor->set_tooltip(text); return; @@ -2703,6 +2841,7 @@ void AnimationKeyEditor::_notification(int p_what) { //menu_track->get_popup()->add_submenu_item("Set Transitions..","Transitions"); //menu_track->get_popup()->add_separator(); menu_track->get_popup()->add_item("Optimize Animation",TRACK_MENU_OPTIMIZE); + menu_track->get_popup()->add_item("Clean-Up Animation",TRACK_MENU_CLEAN_UP); curve_linear->set_icon(get_icon("CurveLinear","EditorIcons")); curve_in->set_icon(get_icon("CurveIn","EditorIcons")); @@ -3862,6 +4001,32 @@ AnimationKeyEditor::AnimationKeyEditor(UndoRedo *p_undo_redo, EditorHistory *p_h add_child(call_select); call_select->set_title("Call Functions in Which Node?"); + cleanup_dialog = memnew( ConfirmationDialog ); + add_child(cleanup_dialog); + VBoxContainer *cleanup_vb = memnew( VBoxContainer ); + cleanup_dialog->add_child(cleanup_vb); + cleanup_dialog->set_child_rect(cleanup_vb); + cleanup_keys = memnew( CheckButton ); + cleanup_keys->set_text("Remove invalid keys"); + cleanup_keys->set_pressed(true); + cleanup_vb->add_child(cleanup_keys); + + cleanup_tracks = memnew( CheckButton ); + cleanup_tracks->set_text("Remove unresolved and empty tracks"); + cleanup_tracks->set_pressed(true); + cleanup_vb->add_child(cleanup_tracks); + + cleanup_all = memnew( CheckButton ); + cleanup_all->set_text("Clean-Up all animations"); + cleanup_vb->add_child(cleanup_all); + + cleanup_dialog->set_title("Clean up Animation(s) (NO UNDO!)"); + cleanup_dialog->get_ok()->set_text("Clean-Up"); + + cleanup_dialog->connect("confirmed",this,"_menu_track",varray(TRACK_MENU_CLEAN_UP_CONFIRM)); + + + } AnimationKeyEditor::~AnimationKeyEditor() { diff --git a/tools/editor/animation_editor.h b/tools/editor/animation_editor.h index 629377d78e..743242fe94 100644 --- a/tools/editor/animation_editor.h +++ b/tools/editor/animation_editor.h @@ -89,6 +89,8 @@ class AnimationKeyEditor : public VBoxContainer { TRACK_MENU_NEXT_STEP, TRACK_MENU_PREV_STEP, TRACK_MENU_OPTIMIZE, + TRACK_MENU_CLEAN_UP, + TRACK_MENU_CLEAN_UP_CONFIRM, CURVE_SET_LINEAR, CURVE_SET_IN, CURVE_SET_OUT, @@ -190,6 +192,11 @@ class AnimationKeyEditor : public VBoxContainer { SpinBox *optimize_angular_error; SpinBox *optimize_max_angle; + ConfirmationDialog *cleanup_dialog; + CheckButton *cleanup_keys; + CheckButton *cleanup_tracks; + CheckButton *cleanup_all; + SpinBox *step; MenuButton *menu_add_track; @@ -284,6 +291,7 @@ class AnimationKeyEditor : public VBoxContainer { void _animation_changed(); void _animation_optimize(); + void _cleanup_animation(Ref<Animation> p_animation); void _scroll_changed(double); diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 685763cadb..0728b3b7c1 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -614,6 +614,7 @@ CodeTextEditor::CodeTextEditor() { text_editor->add_font_override("font",get_font("source","Fonts")); text_editor->set_show_line_numbers(true); text_editor->set_brace_matching(true); + text_editor->set_auto_indent(true); line_col = memnew( Label ); add_child(line_col); diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index b0bacdae61..d4937d7114 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -163,6 +163,7 @@ void ConnectDialog::edit(Node *p_node) { dst_path->set_text(""); dst_method->set_text(""); deferred->set_pressed(false); + oneshot->set_pressed(false); cdbinds->params.clear(); cdbinds->notify_changed(); } @@ -196,6 +197,11 @@ bool ConnectDialog::get_deferred() const { return deferred->is_pressed(); } +bool ConnectDialog::get_oneshot() const { + + return oneshot->is_pressed(); +} + StringName ConnectDialog::get_dst_method() const { String txt=dst_method->get_text(); @@ -423,12 +429,13 @@ ConnectDialog::ConnectDialog() { dstm_hb->add_child(make_callback); deferred = memnew( CheckButton ); - deferred->set_toggle_mode(true); - deferred->set_pressed(true); deferred->set_text("Deferred"); dstm_hb->add_child(deferred); - + oneshot = memnew( CheckButton ); + oneshot->set_text("Oneshot"); + dstm_hb->add_child(oneshot); + /* realtime = memnew( CheckButton ); realtime->set_anchor( MARGIN_TOP, ANCHOR_END ); @@ -496,11 +503,13 @@ void ConnectionsDialog::_connect() { StringName dst_method=connect_dialog->get_dst_method(); bool defer=connect_dialog->get_deferred(); + bool oshot=connect_dialog->get_oneshot(); Vector<Variant> binds = connect_dialog->get_binds(); StringArray args = it->get_metadata(0).operator Dictionary()["args"]; + int flags = CONNECT_PERSIST | (defer?CONNECT_DEFERRED:0) | (oshot?CONNECT_ONESHOT:0); undo_redo->create_action("Connect '"+signal+"' to '"+String(dst_method)+"'"); - undo_redo->add_do_method(node,"connect",signal,target,dst_method,binds,CONNECT_PERSIST | (defer?CONNECT_DEFERRED:0)); + undo_redo->add_do_method(node,"connect",signal,target,dst_method,binds,flags); undo_redo->add_undo_method(node,"disconnect",signal,target,dst_method); undo_redo->add_do_method(this,"update_tree"); undo_redo->add_undo_method(this,"update_tree"); @@ -731,6 +740,8 @@ void ConnectionsDialog::update_tree() { String path = String(node->get_path_to(target))+" :: "+c.method+"()"; if (c.flags&CONNECT_DEFERRED) path+=" (deferred)"; + if (c.flags&CONNECT_ONESHOT) + path+=" (oneshot)"; if (c.binds.size()) { path+=" binds( "; diff --git a/tools/editor/connections_dialog.h b/tools/editor/connections_dialog.h index 68b13bf07a..4a1c3f189c 100644 --- a/tools/editor/connections_dialog.h +++ b/tools/editor/connections_dialog.h @@ -58,6 +58,7 @@ class ConnectDialog : public ConfirmationDialog { //MenuButton *dst_method_list; OptionButton *type_list; CheckButton *deferred; + CheckButton *oneshot; CheckButton *make_callback; PropertyEditor *bind_editor; Node *node; @@ -80,6 +81,7 @@ public: NodePath get_dst_path() const; StringName get_dst_method() const; bool get_deferred() const; + bool get_oneshot() const; Vector<Variant> get_binds() const; void set_dst_method(const StringName& p_method); void set_dst_node(Node* p_node); diff --git a/tools/editor/dependency_editor.cpp b/tools/editor/dependency_editor.cpp index c04e82a08a..7e63cfb1b4 100644 --- a/tools/editor/dependency_editor.cpp +++ b/tools/editor/dependency_editor.cpp @@ -510,3 +510,184 @@ DependencyErrorDialog::DependencyErrorDialog() { set_title("Errors loading!"); } + +////////////////////////////////////////////////////////////////////// + + + +void OrphanResourcesDialog::ok_pressed() { + + paths.clear(); + + _find_to_delete(files->get_root(),paths); + if (paths.empty()) + return; + + delete_confirm->set_text("Permanently Delete "+itos(paths.size())+" Item(s) ? (No Undo!!)"); + delete_confirm->popup_centered_minsize(); +} + +bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd,HashMap<String,int>& refs,TreeItem* p_parent){ + + + if (!efsd) + return false; + + bool has_childs=false; + + for(int i=0;i<efsd->get_subdir_count();i++) { + + TreeItem *dir_item=NULL; + if (p_parent) { + dir_item = files->create_item(p_parent); + dir_item->set_text(0,efsd->get_subdir(i)->get_name()); + dir_item->set_icon(0,get_icon("folder","FileDialog")); + + } + bool children = _fill_owners(efsd->get_subdir(i),refs,dir_item); + + if (p_parent) { + if (!children) { + memdelete(dir_item); + } else { + has_childs=true; + } + } + + } + + + for(int i=0;i<efsd->get_file_count();i++) { + + if (!p_parent) { + Vector<String> deps = efsd->get_file_deps(i); + //print_line(":::"+efsd->get_file_path(i)); + for(int j=0;j<deps.size();j++) { + + if (!refs.has(deps[j])) { + refs[deps[j]]=1; + } + } + } else { + + String path = efsd->get_file_path(i); + if (!refs.has(path)) { + TreeItem *ti=files->create_item(p_parent); + ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); + ti->set_text(0,efsd->get_file(i)); + ti->set_editable(0,true); + + String type=efsd->get_file_type(i); + + Ref<Texture> icon; + if (has_icon(type,"EditorIcons")) { + icon=get_icon(type,"EditorIcons"); + } else { + icon=get_icon("Object","EditorIcons"); + } + ti->set_icon(0,icon); + int ds = efsd->get_file_deps(i).size(); + ti->set_text(1,itos(ds)); + if (ds) { + ti->add_button(1,get_icon("Visible","EditorIcons")); + } + ti->set_metadata(0,path); + has_childs=true; + } + } + + } + + return has_childs; +} + + +void OrphanResourcesDialog::refresh() { + HashMap<String,int> refs; + _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(),refs,NULL); + files->clear(); + TreeItem *root=files->create_item(); + _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(),refs,root); +} + + +void OrphanResourcesDialog::show(){ + + refresh(); + popup_centered_ratio(); +} + + +void OrphanResourcesDialog::_find_to_delete(TreeItem* p_item,List<String>& paths) { + + while(p_item) { + + if (p_item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK && p_item->is_checked(0)) { + paths.push_back(p_item->get_metadata(0)); + } + + if (p_item->get_children()) { + _find_to_delete(p_item->get_children(),paths); + } + + p_item=p_item->get_next(); + } + + +} + +void OrphanResourcesDialog::_delete_confirm() { + + DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + for (List<String>::Element *E=paths.front();E;E=E->next()) { + + da->remove(E->get()); + EditorFileSystem::get_singleton()->update_file(E->get()); + } + memdelete(da); + refresh(); +} + +void OrphanResourcesDialog::_button_pressed(Object *p_item,int p_column, int p_id) { + + TreeItem *ti=p_item->cast_to<TreeItem>(); + + String path = ti->get_metadata(0); + dep_edit->edit(path); + +} + +void OrphanResourcesDialog::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("_delete_confirm"),&OrphanResourcesDialog::_delete_confirm); + ObjectTypeDB::bind_method(_MD("_button_pressed"),&OrphanResourcesDialog::_button_pressed); + +} + +OrphanResourcesDialog::OrphanResourcesDialog(){ + + VBoxContainer *vbc = memnew( VBoxContainer ); + add_child(vbc); + set_child_rect(vbc); + files = memnew( Tree ); + files->set_columns(2); + files->set_column_titles_visible(true); + files->set_column_min_width(1,100); + files->set_column_expand(0,true); + files->set_column_expand(1,false); + files->set_column_title(0,"Resource"); + files->set_column_title(1,"Owns"); + files->set_hide_root(true); + vbc->add_margin_child("Resources Without Explicit Ownership:",files,true); + set_title("Orphan Resource Explorer"); + delete_confirm = memnew( ConfirmationDialog ); + delete_confirm->set_text("Delete selected files?"); + get_ok()->set_text("Delete"); + add_child(delete_confirm); + dep_edit = memnew( DependencyEditor ); + add_child(dep_edit); + files->connect("button_pressed",this,"_button_pressed"); + delete_confirm->connect("confirmed",this,"_delete_confirm"); + set_hide_on_ok(false); + +} diff --git a/tools/editor/dependency_editor.h b/tools/editor/dependency_editor.h index 1c328e7a93..c372025ca0 100644 --- a/tools/editor/dependency_editor.h +++ b/tools/editor/dependency_editor.h @@ -91,4 +91,29 @@ public: DependencyErrorDialog(); }; + + +class OrphanResourcesDialog : public ConfirmationDialog { + OBJ_TYPE(OrphanResourcesDialog,ConfirmationDialog); + + DependencyEditor *dep_edit; + Tree *files; + ConfirmationDialog *delete_confirm; + void ok_pressed(); + + bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String,int>& refs, TreeItem *p_parent); + + List<String> paths; + void _find_to_delete(TreeItem* p_item,List<String>& paths); + void _delete_confirm(); + void _button_pressed(Object *p_item,int p_column, int p_id); + + void refresh(); + static void _bind_methods(); +public: + + void show(); + OrphanResourcesDialog(); +}; + #endif // DEPENDENCY_EDITOR_H diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index 673ee30adb..a6aedf2706 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -338,6 +338,14 @@ void EditorData::set_editor_states(const Dictionary& p_states) { } +void EditorData::notify_edited_scene_changed() { + + for(int i=0;i<editor_plugins.size();i++) { + + editor_plugins[i]->edited_scene_changed(); + } +} + void EditorData::clear_editor_states() { for(int i=0;i<editor_plugins.size();i++) { diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h index c5ee83ae63..a90a071c39 100644 --- a/tools/editor/editor_data.h +++ b/tools/editor/editor_data.h @@ -200,6 +200,7 @@ public: void save_edited_scene_state(EditorSelection *p_selection,EditorHistory *p_history,const Dictionary& p_custom); Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history); + void notify_edited_scene_changed(); EditorData(); diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index c62347d129..104539c308 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -27,14 +27,14 @@ void EditorFileDialog::_notification(int p_what) { dir_prev->set_icon(get_icon("ArrowLeft","EditorIcons")); dir_next->set_icon(get_icon("ArrowRight","EditorIcons")); dir_up->set_icon(get_icon("ArrowUp","EditorIcons")); + refresh->set_icon(get_icon("Reload","EditorIcons")); favorite->set_icon(get_icon("Favorites","EditorIcons")); fav_up->set_icon(get_icon("MoveUp","EditorIcons")); fav_down->set_icon(get_icon("MoveDown","EditorIcons")); fav_rm->set_icon(get_icon("RemoveSmall","EditorIcons")); - } - if (p_what==NOTIFICATION_PROCESS) { + } else if (p_what==NOTIFICATION_PROCESS) { if (preview_waiting) { preview_wheel_timeout-=get_process_delta_time(); @@ -47,12 +47,17 @@ void EditorFileDialog::_notification(int p_what) { preview_wheel_timeout=0.1; } } - } - - if (p_what==NOTIFICATION_DRAW) { + } else if (p_what==NOTIFICATION_DRAW) { //RID ci = get_canvas_item(); //get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size())); + } else if (p_what==EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { + + bool show_hidden = EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"); + + if (show_hidden != show_hidden_files) { + set_show_hidden_files(show_hidden); + } } } @@ -1012,7 +1017,7 @@ void EditorFileDialog::_go_forward(){ } -bool EditorFileDialog::default_show_hidden_files=true; +bool EditorFileDialog::default_show_hidden_files=false; void EditorFileDialog::set_display_mode(DisplayMode p_mode) { @@ -1141,7 +1146,7 @@ void EditorFileDialog::_save_to_recent() { EditorFileDialog::EditorFileDialog() { - show_hidden_files=true; + show_hidden_files=default_show_hidden_files; display_mode=DISPLAY_THUMBNAILS; local_history_pos=0; @@ -1170,6 +1175,10 @@ EditorFileDialog::EditorFileDialog() { pathhb->add_child(dir); dir->set_h_size_flags(SIZE_EXPAND_FILL); + refresh = memnew( ToolButton ); + refresh->connect("pressed",this,"_update_file_list"); + pathhb->add_child(refresh); + favorite = memnew( ToolButton ); favorite->set_toggle_mode(true); favorite->connect("toggled",this,"_favorite_toggled"); diff --git a/tools/editor/editor_file_dialog.h b/tools/editor/editor_file_dialog.h index 6cfd970516..eb38c3c02f 100644 --- a/tools/editor/editor_file_dialog.h +++ b/tools/editor/editor_file_dialog.h @@ -108,6 +108,7 @@ private: ToolButton *mode_list; + ToolButton *refresh; ToolButton *favorite; ToolButton *fav_up; diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index 321ac76240..a5a3890129 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -36,6 +36,14 @@ #include "os/keyboard.h" +void EditorHelpSearch::popup() { + popup_centered_ratio(0.6); + if (search_box->get_text()!="") { + search_box->select_all(); + _update_search(); + } + search_box->grab_focus(); +} void EditorHelpSearch::popup(const String& p_term) { @@ -263,7 +271,7 @@ void EditorHelpSearch::_confirmed() { String mdata=ti->get_metadata(0); emit_signal("go_to_help",mdata); - editor->call("_editor_select",3); // in case EditorHelpSearch beeen invoked on top of other editor window + editor->call("_editor_select",EditorNode::EDITOR_SCRIPT); // in case EditorHelpSearch beeen invoked on top of other editor window // go to that hide(); } @@ -1049,7 +1057,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { void EditorHelp::_request_help(const String& p_string) { Error err = _goto_desc(p_string); if (err==OK) { - editor->call("_editor_select",3); + editor->call("_editor_select",EditorNode::EDITOR_SCRIPT); } //100 palabras } @@ -1089,7 +1097,7 @@ void EditorHelp::_help_callback(const String& p_topic) { line=constant_line[name]; } - class_desc->scroll_to_line(line); + class_desc->call_deferred("scroll_to_line", line); } @@ -1350,7 +1358,6 @@ void EditorHelp::_notification(int p_what) { // forward->set_icon(get_icon("Forward","EditorIcons")); // back->set_icon(get_icon("Back","EditorIcons")); _update_doc(); - editor->connect("request_help",this,"_request_help"); } break; } @@ -1408,7 +1415,6 @@ void EditorHelp::_bind_methods() { ObjectTypeDB::bind_method("_unhandled_key_input",&EditorHelp::_unhandled_key_input); ObjectTypeDB::bind_method("_search",&EditorHelp::_search); ObjectTypeDB::bind_method("_search_cbk",&EditorHelp::_search_cbk); - ObjectTypeDB::bind_method("_help_callback",&EditorHelp::_help_callback); ADD_SIGNAL(MethodInfo("go_to_help")); diff --git a/tools/editor/editor_help.h b/tools/editor/editor_help.h index b5ee6eca6c..04ac4d35ff 100644 --- a/tools/editor/editor_help.h +++ b/tools/editor/editor_help.h @@ -68,7 +68,8 @@ protected: static void _bind_methods(); public: - void popup(const String& p_term=""); + void popup(); + void popup(const String& p_term); EditorHelpSearch(); }; diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index f52c6e67a2..cd455406b7 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -399,6 +399,40 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const } +String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { + String user_file = EditorSettings::get_singleton()->get_settings_path() + +"/templates/"+template_file_name; + String system_file=OS::get_singleton()->get_installed_templates_path(); + bool has_system_path=(system_file!=""); + system_file+=template_file_name; + + // Prefer user file + if (FileAccess::exists(user_file)) { + return user_file; + } + + // Now check system file + if (has_system_path) { + if (FileAccess::exists(system_file)) { + return system_file; + } + } + + // Not found + if (err) { + *err+="No export template found at \""+user_file+"\""; + if (has_system_path) + *err+="\n or \""+system_file+"\"."; + else + *err+="."; + } + return ""; +} + +bool EditorExportPlatform::exists_export_template(String template_file_name, String *err) const { + return find_export_template(template_file_name,err)!=""; +} + /////////////////////////////////////// @@ -1131,19 +1165,32 @@ Error EditorExportPlatformPC::export_project(const String& p_path, bool p_debug, ep.step("Setting Up..",0); - String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - if (use64) { - if (p_debug) - exe_path=custom_debug_binary!=""?custom_debug_binary:exe_path+debug_binary64; - else - exe_path=custom_release_binary!=""?custom_release_binary:exe_path+release_binary64; - } else { + String exe_path=""; - if (p_debug) - exe_path=custom_debug_binary!=""?custom_debug_binary:exe_path+debug_binary32; - else - exe_path=custom_release_binary!=""?custom_release_binary:exe_path+release_binary32; + if (p_debug) + exe_path=custom_debug_binary; + else + exe_path=custom_release_binary; + if (exe_path=="") { + String fname; + if (use64) { + if (p_debug) + fname=debug_binary64; + else + fname=release_binary64; + } else { + if (p_debug) + fname=debug_binary32; + else + fname=release_binary32; + } + String err=""; + exe_path=find_export_template(fname,&err); + if (exe_path=="") { + EditorNode::add_io_error(err); + return ERR_FILE_CANT_READ; + } } FileAccess *src_exe=FileAccess::open(exe_path,FileAccess::READ); @@ -1207,14 +1254,12 @@ bool EditorExportPlatformPC::can_export(String *r_error) const { String err; bool valid=true; - String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - - if (use64 && (!FileAccess::exists(exe_path+debug_binary64) || !FileAccess::exists(exe_path+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"; } - if (!use64 && (!FileAccess::exists(exe_path+debug_binary32) || !FileAccess::exists(exe_path+release_binary32))) { + if (!use64 && (!exists_export_template(debug_binary32) || !exists_export_template(release_binary32))) { valid=false; err="No 32 bits export templates found.\nDownload and install export templates.\n"; } @@ -1562,6 +1607,17 @@ void EditorImportExport::image_export_get_images_in_group(const StringName& p_gr } } +void EditorImportExport::set_convert_text_scenes(bool p_convert) { + + convert_text_scenes=p_convert; +} + +bool EditorImportExport::get_convert_text_scenes() const{ + + return convert_text_scenes; +} + + void EditorImportExport::load_config() { Ref<ConfigFile> cf = memnew( ConfigFile ); @@ -1604,6 +1660,12 @@ void EditorImportExport::load_config() { } } + if (cf->has_section("convert_scenes")) { + + convert_text_scenes = cf->get_value("convert_scenes","convert_text_scenes"); + } + + if (cf->has_section("export_filter_files")) { @@ -1837,6 +1899,8 @@ void EditorImportExport::save_config() { case SCRIPT_ACTION_ENCRYPT: cf->set_value("script","action","encrypt"); break; } + cf->set_value("convert_scenes","convert_text_scenes",convert_text_scenes); + cf->set_value("script","encrypt_key",script_key); switch(sample_action) { @@ -1935,6 +1999,8 @@ EditorImportExport::EditorImportExport() { sample_action_max_hz=44100; sample_action_trim=false; + convert_text_scenes=true; + } diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index 1a3171e66b..93086f7ad4 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -86,6 +86,8 @@ protected: Vector<uint8_t> get_exported_file_default(String& p_fname) const; virtual Vector<uint8_t> get_exported_file(String& p_fname) const; virtual Vector<StringName> get_dependencies(bool p_bundles) const; + virtual String find_export_template(String template_file_name, String *err=NULL) const; + virtual bool exists_export_template(String template_file_name, String *err=NULL) const; struct TempData { @@ -284,6 +286,8 @@ protected: int sample_action_max_hz; bool sample_action_trim; + bool convert_text_scenes; + static EditorImportExport* singleton; static void _bind_methods(); @@ -362,6 +366,9 @@ public: void sample_set_trim(bool p_trim); bool sample_get_trim() const; + void set_convert_text_scenes(bool p_convert); + bool get_convert_text_scenes() const; + void load_config(); void save_config(); diff --git a/tools/editor/editor_layout_dialog.cpp b/tools/editor/editor_layout_dialog.cpp new file mode 100644 index 0000000000..e37f263c0c --- /dev/null +++ b/tools/editor/editor_layout_dialog.cpp @@ -0,0 +1,59 @@ +/*************************************************************************/ +/* editor_node.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "editor_layout_dialog.h" +#include "object_type_db.h" + +void EditorLayoutDialog::clear_layout_name() { + + layout_name->clear(); +} + +void EditorLayoutDialog::ok_pressed() { + + if (layout_name->get_text()!="") { + emit_signal("layout_selected", layout_name->get_text()); + } +} + +void EditorLayoutDialog::_bind_methods() { + + ADD_SIGNAL(MethodInfo("layout_selected",PropertyInfo( Variant::STRING,"layout_name"))); +} + +EditorLayoutDialog::EditorLayoutDialog() +{ + + layout_name = memnew( LineEdit ); + layout_name->set_margin(MARGIN_TOP,5); + layout_name->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5); + layout_name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5); + add_child(layout_name); + move_child(layout_name, get_label()->get_index()+1); +} diff --git a/tools/editor/editor_layout_dialog.h b/tools/editor/editor_layout_dialog.h new file mode 100644 index 0000000000..7e3b9e3d8a --- /dev/null +++ b/tools/editor/editor_layout_dialog.h @@ -0,0 +1,53 @@ +/*************************************************************************/ +/* editor_layout_dialog.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef EDITOR_LAYOUT_DIALOG_H +#define EDITOR_LAYOUT_DIALOG_H + +#include "scene/gui/dialogs.h" +#include "scene/gui/line_edit.h" + +class EditorLayoutDialog : public ConfirmationDialog { + + OBJ_TYPE( EditorLayoutDialog, ConfirmationDialog ); + + LineEdit *layout_name; + +protected: + + static void _bind_methods(); + virtual void ok_pressed(); + +public: + void clear_layout_name(); + + EditorLayoutDialog(); +}; + +#endif // EDITOR_LAYOUT_DIALOG_H diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 4e22592880..35404b0bba 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -102,6 +102,7 @@ #include "tools/editor/io_plugins/editor_sample_import_plugin.h" #include "tools/editor/io_plugins/editor_translation_import_plugin.h" #include "tools/editor/io_plugins/editor_mesh_import_plugin.h" +#include "tools/editor/io_plugins/editor_export_scene.h" #include "plugins/editor_preview_plugins.h" @@ -167,11 +168,20 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) { /*case KEY_F1: if (!p_event.key.mod.shift && !p_event.key.mod.command) - _editor_select(3); + _editor_select(EDITOR_SCRIPT); break;*/ - case KEY_F1: _editor_select(0); break; - case KEY_F2: _editor_select(1); break; - case KEY_F3: _editor_select(2); break; + case KEY_F1: + if (!p_event.key.mod.shift && !p_event.key.mod.command) + _editor_select(EDITOR_2D); + break; + case KEY_F2: + if (!p_event.key.mod.shift && !p_event.key.mod.command) + _editor_select(EDITOR_3D); + break; + case KEY_F3: + if (!p_event.key.mod.shift && !p_event.key.mod.command) + _editor_select(EDITOR_SCRIPT); + break; case KEY_F5: _menu_option_confirm((p_event.key.mod.control&&p_event.key.mod.shift)?RUN_PLAY_CUSTOM_SCENE:RUN_PLAY,true); break; case KEY_F6: _menu_option_confirm(RUN_PLAY_SCENE,true); break; case KEY_F7: _menu_option_confirm(RUN_PAUSE,true); break; @@ -289,7 +299,7 @@ void EditorNode::_notification(int p_what) { VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport(),true); VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(),true); - _editor_select(1); + _editor_select(EDITOR_3D); if (defer_load_scene!="") { @@ -533,7 +543,6 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) { } - void EditorNode::_menu_option(int p_option) { _menu_option_confirm(p_option,false); @@ -879,7 +888,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { } } - _editor_select(is2d?0:1); + _editor_select(is2d?EDITOR_2D:EDITOR_3D); VS::get_singleton()->viewport_queue_screen_capture(viewport); save.step("Creating Thumbnail",2); @@ -1400,6 +1409,69 @@ void EditorNode::_dialog_action(String p_file) { save_resource_in_path(current_res,p_file); } break; + case SETTINGS_LAYOUT_SAVE: { + + if (p_file.empty()) + return; + + if (p_file=="Default") { + confirm_error->set_text("Cannot overwrite default layout!"); + confirm_error->popup_centered_minsize(); + return; + } + + Ref<ConfigFile> config; + config.instance(); + Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg")); + if (err!=OK && err!=ERR_FILE_NOT_FOUND) { + return; //no config + } + + _save_docks_to_config(config, p_file); + + config->save(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg")); + + layout_dialog->hide(); + _update_layouts_menu(); + + } break; + case SETTINGS_LAYOUT_DELETE: { + + if (p_file.empty()) + return; + + if (p_file=="Default") { + confirm_error->set_text("Cannot delete default layout!"); + confirm_error->popup_centered_minsize(); + return; + } + + Ref<ConfigFile> config; + config.instance(); + Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg")); + if (err!=OK) { + return; //no config + } + + if (!config->has_section(p_file)) { + confirm_error->set_text("Layout name not found!"); + confirm_error->popup_centered_minsize(); + return; + } + + // erase + List<String> keys; + config->get_section_keys(p_file, &keys); + for (List<String>::Element *E=keys.front();E;E=E->next()) { + config->set_value(p_file, E->get(), Variant()); + } + + config->save(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg")); + + layout_dialog->hide(); + _update_layouts_menu(); + + } break; default: { //save scene? if (file->get_mode()==FileDialog::MODE_SAVE_FILE) { @@ -1553,6 +1625,10 @@ void EditorNode::_edit_current() { scene_tree_dock->set_selected(NULL); property_editor->edit( NULL ); object_menu->set_disabled(true); + + if (editor_plugin_over) + editor_plugin_over->make_visible(false); + return; } @@ -2028,7 +2104,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { return; }; // fallthrough to save_as - } break; + }; case FILE_SAVE_AS_SCENE: { Node *scene = editor_data.get_edited_scene_root(); @@ -2379,6 +2455,10 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { log->add_message("REDO: "+action); } break; + case TOOLS_ORPHAN_RESOURCES: { + + orphan_resources->show(); + } break; case EDIT_REVERT: { @@ -2519,7 +2599,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { case OBJECT_REQUEST_HELP: { if (current) { - _editor_select(3); + _editor_select(EDITOR_SCRIPT); emit_signal("request_help",current->get_type()); } @@ -3296,9 +3376,9 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) { int n2d=0,n3d=0; _find_node_types(get_edited_scene(),n2d,n3d); if (n2d>n3d) { - _editor_select(0); + _editor_select(EDITOR_2D); } else if (n3d>n2d) { - _editor_select(1); + _editor_select(EDITOR_3D); } } @@ -3319,6 +3399,8 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) { //changing_scene=true; //avoid script change from opening editor ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root(); ScriptEditor::get_singleton()->set_scene_root_script( editor_data.get_scene_root_script(editor_data.get_edited_scene()) ); + editor_data.notify_edited_scene_changed(); + //changing_scene=false; } @@ -3534,13 +3616,14 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo if (p_set_inherited) { Ref<SceneState> state = sdata->get_state(); - state->set_path(lpath); + state->set_path(lpath); new_scene->set_scene_inherited_state(state); new_scene->set_filename(String()); - if (new_scene->get_scene_instance_state().is_valid()) - new_scene->get_scene_instance_state()->set_path(String()); + //if (new_scene->get_scene_instance_state().is_valid()) + // new_scene->get_scene_instance_state()->set_path(String()); } + new_scene->set_scene_instance_state(Ref<SceneState>()); set_edited_scene(new_scene); _get_scene_metadata(); @@ -3857,7 +3940,8 @@ bool EditorNode::_find_editing_changed_scene(Node *p_from) { void EditorNode::add_io_error(const String& p_error) { - + CharString err_ut = p_error.utf8(); + ERR_PRINT(err_ut.get_data()); _load_error_notify(singleton,p_error); } @@ -4013,6 +4097,9 @@ void EditorNode::_bind_methods() { ObjectTypeDB::bind_method("_dock_move_left",&EditorNode::_dock_move_left); ObjectTypeDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right); + ObjectTypeDB::bind_method("_layout_menu_option",&EditorNode::_layout_menu_option); + ObjectTypeDB::bind_method("_layout_dialog_action",&EditorNode::_dialog_action); + ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene); ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version); ObjectTypeDB::bind_method("_scene_tab_changed",&EditorNode::_scene_tab_changed); @@ -4307,6 +4394,15 @@ void EditorNode::_save_docks() { Ref<ConfigFile> config; config.instance(); + _save_docks_to_config(config, "docks"); + editor_data.get_plugin_window_layout(config); + + config->save(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg")); + +} + +void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String& p_section) { + for(int i=0;i<DOCK_SLOT_MAX;i++) { String names; for(int j=0;j<dock_slot[i]->get_tab_count();j++) { @@ -4317,7 +4413,7 @@ void EditorNode::_save_docks() { } if (names!="") { - config->set_value("docks","dock_"+itos(i+1),names); + p_layout->set_value(p_section,"dock_"+itos(i+1),names); } } @@ -4331,7 +4427,7 @@ void EditorNode::_save_docks() { for(int i=0;i<DOCK_SLOT_MAX/2;i++) { if (splits[i]->is_visible()) { - config->set_value("docks","dock_split_"+itos(i+1),splits[i]->get_split_offset()); + p_layout->set_value(p_section,"dock_split_"+itos(i+1),splits[i]->get_split_offset()); } } @@ -4345,13 +4441,9 @@ void EditorNode::_save_docks() { for(int i=0;i<4;i++) { - config->set_value("docks","dock_hsplit_"+itos(i+1),h_splits[i]->get_split_offset()); + p_layout->set_value(p_section,"dock_hsplit_"+itos(i+1),h_splits[i]->get_split_offset()); } - editor_data.get_plugin_window_layout(config); - - config->save(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg")); - } void EditorNode::save_layout() { @@ -4373,12 +4465,19 @@ void EditorNode::_load_docks() { return; //no config } + _load_docks_from_config(config, "docks"); + editor_data.set_plugin_window_layout(config); + +} + +void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section) { + for(int i=0;i<DOCK_SLOT_MAX;i++) { - if (!config->has_section_key("docks","dock_"+itos(i+1))) + if (!p_layout->has_section_key(p_section,"dock_"+itos(i+1))) continue; - Vector<String> names = String(config->get_value("docks","dock_"+itos(i+1))).split(","); + Vector<String> names = String(p_layout->get_value(p_section,"dock_"+itos(i+1))).split(","); for(int j=0;j<names.size();j++) { @@ -4398,7 +4497,7 @@ void EditorNode::_load_docks() { if (atidx==-1) //well, it's not anywhere continue; - if (atidx==j) { + if (atidx==i) { node->raise(); continue; } @@ -4413,7 +4512,6 @@ void EditorNode::_load_docks() { dock_slot[i]->add_child(node); dock_slot[i]->show(); } - } VSplitContainer*splits[DOCK_SLOT_MAX/2]={ @@ -4425,14 +4523,14 @@ void EditorNode::_load_docks() { for(int i=0;i<DOCK_SLOT_MAX/2;i++) { - if (!config->has_section_key("docks","dock_split_"+itos(i+1))) + if (!p_layout->has_section_key(p_section,"dock_split_"+itos(i+1))) continue; - int ofs = config->get_value("docks","dock_split_"+itos(i+1)); + int ofs = p_layout->get_value(p_section,"dock_split_"+itos(i+1)); splits[i]->set_split_offset(ofs); } - HSplitContainer *h_splits[4]={ + HSplitContainer*h_splits[4]={ left_l_hsplit, left_r_hsplit, main_hsplit, @@ -4440,9 +4538,9 @@ void EditorNode::_load_docks() { }; for(int i=0;i<4;i++) { - if (!config->has_section_key("docks","dock_hsplit_"+itos(i+1))) + if (!p_layout->has_section_key(p_section,"dock_hsplit_"+itos(i+1))) continue; - int ofs = config->get_value("docks","dock_hsplit_"+itos(i+1)); + int ofs = p_layout->get_value(p_section,"dock_hsplit_"+itos(i+1)); h_splits[i]->set_split_offset(ofs); } @@ -4460,8 +4558,78 @@ void EditorNode::_load_docks() { dock_slot[i]->set_current_tab(0); } } +} - editor_data.set_plugin_window_layout(config); + +void EditorNode::_update_layouts_menu() { + + editor_layouts->clear(); + editor_layouts->set_size(Vector2()); + editor_layouts->add_item("Save Layout", SETTINGS_LAYOUT_SAVE); + editor_layouts->add_item("Delete Layout", SETTINGS_LAYOUT_DELETE); + editor_layouts->add_separator(); + editor_layouts->add_item("Default", SETTINGS_LAYOUT_DEFAULT); + + Ref<ConfigFile> config; + config.instance(); + Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg")); + if (err!=OK) { + return; //no config + } + + List<String> layouts; + config.ptr()->get_sections(&layouts); + + for (List<String>::Element *E=layouts.front();E;E=E->next()) { + + String layout=E->get(); + + if (layout!="Default") + editor_layouts->add_item(layout); + } + +} + +void EditorNode::_layout_menu_option(int p_id) { + + switch (p_id) { + + case SETTINGS_LAYOUT_SAVE: { + + current_option=p_id; + layout_dialog->clear_layout_name(); + layout_dialog->set_title("Save Layout"); + layout_dialog->get_ok()->set_text("Save"); + layout_dialog->popup_centered(); + } break; + case SETTINGS_LAYOUT_DELETE: { + + current_option=p_id; + layout_dialog->clear_layout_name(); + layout_dialog->set_title("Delete Layout"); + layout_dialog->get_ok()->set_text("Delete"); + layout_dialog->popup_centered(); + } break; + case SETTINGS_LAYOUT_DEFAULT: { + + _load_docks_from_config(default_theme, "docks"); + _save_docks(); + } break; + default: { + + Ref<ConfigFile> config; + config.instance(); + Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg")); + if (err!=OK) { + return; //no config + } + + int idx=editor_layouts->get_item_index(p_id); + _load_docks_from_config(config, editor_layouts->get_item_text(idx)); + _save_docks(); + + } + } } @@ -4574,6 +4742,7 @@ EditorNode::EditorNode() { 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")); ResourceLoader::set_error_notify_func(this,_load_error_notify); ResourceLoader::set_dependency_error_notify_func(this,_dependency_error_report); @@ -5037,6 +5206,17 @@ EditorNode::EditorNode() { p=import_menu->get_popup(); p->connect("item_pressed",this,"_menu_option"); + tool_menu = memnew( MenuButton ); + tool_menu->set_tooltip("Miscelaneous project or scene wide tools."); + tool_menu->set_text("Tools"); + + //tool_menu->set_icon(gui_base->get_icon("Save","EditorIcons")); + left_menu_hb->add_child( tool_menu ); + + p=tool_menu->get_popup(); + p->connect("item_pressed",this,"_menu_option"); + p->add_item("Orphan Resource Explorer",TOOLS_ORPHAN_RESOURCES); + export_button = memnew( ToolButton ); export_button->set_tooltip("Export the project to many platforms."); export_button->set_text("Export"); @@ -5205,17 +5385,29 @@ EditorNode::EditorNode() { right_menu_hb->add_child( settings_menu ); p=settings_menu->get_popup(); - //p->add_item("Export Settings",SETTINGS_EXPORT_PREFERENCES); p->add_item("Editor Settings",SETTINGS_PREFERENCES); //p->add_item("Optimization Presets",SETTINGS_OPTIMIZED_PRESETS); p->add_separator(); + editor_layouts = memnew( PopupMenu ); + editor_layouts->set_name("Layouts"); + p->add_child(editor_layouts); + editor_layouts->connect("item_pressed",this,"_layout_menu_option"); + p->add_submenu_item("Editor Layout", "Layouts"); + p->add_separator(); p->add_check_item("Show Animation",SETTINGS_SHOW_ANIMATION,KEY_MASK_CMD+KEY_N); p->add_separator(); p->add_item("Install Export Templates",SETTINGS_LOAD_EXPORT_TEMPLATES); p->add_separator(); p->add_item("About",SETTINGS_ABOUT); + layout_dialog = memnew( EditorLayoutDialog ); + gui_base->add_child(layout_dialog); + layout_dialog->set_hide_on_ok(false); + layout_dialog->set_size(Size2(175, 70)); + confirm_error = memnew( AcceptDialog ); + layout_dialog->add_child(confirm_error); + layout_dialog->connect("layout_selected", this,"_layout_dialog_action"); sources_button = memnew( ToolButton ); right_menu_hb->add_child(sources_button); @@ -5402,7 +5594,19 @@ EditorNode::EditorNode() { scenes_dock->connect("open",this,"open_request"); scenes_dock->connect("instance",this,"_instance_request"); + const String docks_section = "docks"; + default_theme.instance(); + default_theme->set_value(docks_section, "dock_3", "Scene"); + default_theme->set_value(docks_section, "dock_4", "FileSystem"); + default_theme->set_value(docks_section, "dock_5", "Inspector"); + + for(int i=0;i<DOCK_SLOT_MAX/2;i++) + default_theme->set_value(docks_section, "dock_hsplit_"+itos(i+1), 0); + for(int i=0;i<DOCK_SLOT_MAX/2;i++) + default_theme->set_value(docks_section, "dock_split_"+itos(i+1), 0); + + _update_layouts_menu(); log = memnew( EditorLog ); center_split->add_child(log); @@ -5465,7 +5669,8 @@ EditorNode::EditorNode() { - + orphan_resources = memnew( OrphanResourcesDialog ); + gui_base->add_child(orphan_resources); @@ -5657,6 +5862,7 @@ EditorNode::EditorNode() { editor_import_export->add_export_plugin( Ref<EditorTextureExportPlugin>( memnew(EditorTextureExportPlugin))); editor_import_export->add_export_plugin( Ref<EditorSampleExportPlugin>( memnew(EditorSampleExportPlugin))); + editor_import_export->add_export_plugin( Ref<EditorSceneExportPlugin>( memnew(EditorSceneExportPlugin))); add_editor_plugin( memnew( CanvasItemEditorPlugin(this) ) ); add_editor_plugin( memnew( SpatialEditorPlugin(this) ) ); @@ -5709,7 +5915,7 @@ EditorNode::EditorNode() { resource_preview->add_preview_generator( Ref<EditorMeshPreviewPlugin>( memnew(EditorMeshPreviewPlugin ))); circle_step_msec=OS::get_singleton()->get_ticks_msec(); - circle_step_frame=OS::get_singleton()->get_frames_drawn();; + circle_step_frame=OS::get_singleton()->get_frames_drawn(); circle_step=0; _rebuild_import_menu(); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 7d8b97688e..bd25f27c59 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -76,6 +76,7 @@ #include "editor_reimport_dialog.h" #include "import_settings.h" #include "tools/editor/editor_plugin.h" +#include "tools/editor/editor_layout_dialog.h" #include "fileserver/editor_file_server.h" #include "editor_resource_preview.h" @@ -133,6 +134,7 @@ class EditorNode : public Node { EDIT_UNDO, EDIT_REDO, EDIT_REVERT, + TOOLS_ORPHAN_RESOURCES, RESOURCE_NEW, RESOURCE_LOAD, RESOURCE_SAVE, @@ -166,6 +168,9 @@ class EditorNode : public Node { SETTINGS_EXPORT_PREFERENCES, SETTINGS_PREFERENCES, SETTINGS_OPTIMIZED_PRESETS, + SETTINGS_LAYOUT_SAVE, + SETTINGS_LAYOUT_DELETE, + SETTINGS_LAYOUT_DEFAULT, SETTINGS_SHOW_ANIMATION, SETTINGS_LOAD_EXPORT_TEMPLATES, SETTINGS_HELP, @@ -237,6 +242,7 @@ class EditorNode : public Node { Control *viewport; MenuButton *file_menu; MenuButton *import_menu; + MenuButton *tool_menu; ToolButton *export_button; ToolButton *prev_scene; MenuButton *object_menu; @@ -282,6 +288,11 @@ class EditorNode : public Node { AcceptDialog *about; AcceptDialog *warning; + Ref<ConfigFile> default_theme; + PopupMenu *editor_layouts; + EditorLayoutDialog *layout_dialog; + AcceptDialog *confirm_error; + //OptimizedPresetsDialog *optimized_presets; EditorSettingsDialog *settings_config_dialog; RunSettingsDialog *run_settings_dialog; @@ -333,6 +344,7 @@ class EditorNode : public Node { DependencyErrorDialog *dependency_error; DependencyEditor *dependency_fixer; + OrphanResourcesDialog *orphan_resources; TabContainer *dock_slot[DOCK_SLOT_MAX]; Rect2 dock_select_rect[DOCK_SLOT_MAX]; @@ -520,15 +532,26 @@ class EditorNode : public Node { void _save_docks(); void _load_docks(); + void _save_docks_to_config(Ref<ConfigFile> p_layout, const String& p_section); + void _load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section); + + void _update_layouts_menu(); + void _layout_menu_option(int p_idx); void _toggle_search_bar(bool p_pressed); void _clear_search_box(); protected: void _notification(int p_what); - static void _bind_methods(); + static void _bind_methods(); public: + enum EditorTable { + EDITOR_2D = 0, + EDITOR_3D, + EDITOR_SCRIPT + }; + static EditorNode* get_singleton() { return singleton; } diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h index 0f3a1e2e3c..6850be2eaa 100644 --- a/tools/editor/editor_plugin.h +++ b/tools/editor/editor_plugin.h @@ -92,6 +92,7 @@ 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 restore_global_state(); virtual void save_global_state(); diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h index 4ba940cd1c..bdfa5160d6 100644 --- a/tools/editor/editor_settings.h +++ b/tools/editor/editor_settings.h @@ -107,6 +107,7 @@ public: static EditorSettings *get_singleton(); void erase(String p_var); String get_settings_path() const; + String get_global_settings_path() const; String get_project_settings_path() const; const Map<String,Plugin>& get_plugins() const { return plugins; } diff --git a/tools/editor/groups_editor.cpp b/tools/editor/groups_editor.cpp index 2e82854014..bb5e93da34 100644 --- a/tools/editor/groups_editor.cpp +++ b/tools/editor/groups_editor.cpp @@ -27,151 +27,130 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "groups_editor.h" -#include "scene/gui/box_container.h" +#include "scene/gui/box_container.h" #include "scene/gui/label.h" +void GroupsEditor::_add_group(const String& p_group) { -#include "print_string.h" + if (!node) + return; -void GroupsEditor::_notification(int p_what) { - - if (p_what==NOTIFICATION_ENTER_TREE) { - connect("confirmed", this,"_close"); - } - if (p_what==NOTIFICATION_EXIT_TREE) { - disconnect("confirmed", this,"_close"); - } -} + String name = group_name->get_text(); + if (name.strip_edges()=="") + return; -void GroupsEditor::_close() { - - hide(); - -} -void GroupsEditor::_add() { - - if (!node) + if (node->is_in_group(name)) return; - - undo_redo->create_action("Add To Group"); - undo_redo->add_do_method(node,"add_to_group",group_name->get_text(),true); - undo_redo->add_undo_method(node,"remove_from_group",group_name->get_text()); + undo_redo->create_action("Add to Group"); + + undo_redo->add_do_method(node,"add_to_group",name,true); undo_redo->add_do_method(this,"update_tree"); + undo_redo->add_undo_method(node,"remove_from_group",name,get_text()); undo_redo->add_undo_method(this,"update_tree"); undo_redo->commit_action(); } +void GroupsEditor::_remove_group(Object *p_item, int p_column, int p_id) { -void GroupsEditor::_remove() { - - if (!tree->get_selected()) - return; if (!node) return; - TreeItem *sel = tree->get_selected(); - if (!sel) + TreeItem *ti = p_item->cast_to<TreeItem>(); + if (!ti) return; - - node->remove_from_group( sel->get_text(0) ); - update_tree(); + + String name = ti->get_text(0); + + undo_redo->create_action("Remove from Group"); + + undo_redo->add_do_method(node,"remove_from_group",name); + undo_redo->add_do_method(this,"update_tree"); + undo_redo->add_undo_method(node,"add_to_group",name,true); + undo_redo->add_undo_method(this,"update_tree"); + + undo_redo->commit_action(); } +struct _GroupInfoComparator { + + bool operator()(const Node::GroupInfo& p_a, const Node::GroupInfo& p_b) const { + return p_a.name.operator String() < p_b.name.operator String(); + } +}; + void GroupsEditor::update_tree() { - tree->clear(); - + if (!node) return; - - List<GroupInfo> groups; + + List<Node::GroupInfo> groups; node->get_groups(&groups); - + groups.sort_custom<_GroupInfoComparator>(); + TreeItem *root=tree->create_item(); - + for(List<GroupInfo>::Element *E=groups.front();E;E=E->next()) { - - if (!E->get().persistent) + + Node::GroupInfo gi = E->get(); + if (!gi.persistent) continue; + TreeItem *item=tree->create_item(root); - item->set_text(0, E->get().name); - + item->set_text(0, gi.name); + item->add_button(0, get_icon("Remove", "EditorIcons"), 0); } - } void GroupsEditor::set_current(Node* p_node) { - + node=p_node; update_tree(); - } void GroupsEditor::_bind_methods() { - - ObjectTypeDB::bind_method("_add",&GroupsEditor::_add); - ObjectTypeDB::bind_method("_close",&GroupsEditor::_close); - ObjectTypeDB::bind_method("_remove",&GroupsEditor::_remove); + + ObjectTypeDB::bind_method("_add_group",&GroupsEditor::_add_group); + ObjectTypeDB::bind_method("_remove_group",&GroupsEditor::_remove_group); ObjectTypeDB::bind_method("update_tree",&GroupsEditor::update_tree); } GroupsEditor::GroupsEditor() { + node=NULL; + set_title("Group Editor"); - - Label * label = memnew( Label ); - label->set_pos( Point2( 8,11) ); - label->set_text("Groups:"); - - add_child(label); - - group_name = memnew(LineEdit); - group_name->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - group_name->set_begin( Point2( 15,28) ); - group_name->set_end( Point2( 94,48 ) ); - - add_child(group_name); - - tree = memnew( Tree ); - tree->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - tree->set_begin( Point2( 15,52) ); - tree->set_end( Point2( 94,42 ) ); - tree->set_hide_root(true); - add_child(tree); - + + VBoxContainer *vbc = memnew( VBoxContainer ); + add_child(vbc); + set_child_rect(vbc); + + HBoxContainer *hbc = memnew( HBoxContainer ); + vbc->add_margin_child("Group", hbc); + + group_name = memnew( LineEdit ); + group_name->set_h_size_flags(SIZE_EXPAND_FILL); + hbc->add_child(group_name); + group_name->connect("text_entered",this,"_add_group"); + add = memnew( Button ); - add->set_anchor( MARGIN_LEFT, ANCHOR_END ); - add->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - add->set_begin( Point2( 90, 28 ) ); - add->set_end( Point2( 15, 48 ) ); add->set_text("Add"); - - add_child(add); - - remove = memnew( Button ); - remove->set_anchor( MARGIN_LEFT, ANCHOR_END ); - remove->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - remove->set_begin( Point2( 90, 52 ) ); - remove->set_end( Point2( 15, 72 ) ); - remove->set_text("Remove"); - - add_child(remove); + hbc->add_child(add); + add->connect("pressed", this,"_add_group", varray(String())); - get_ok()->set_text("Close"); - - add->connect("pressed", this,"_add"); - remove->connect("pressed", this,"_remove"); + tree = memnew( Tree ); + tree->set_hide_root(true); + tree->set_v_size_flags(SIZE_EXPAND_FILL); + vbc->add_margin_child("Node Group(s)", tree, true); + tree->connect("button_pressed",this,"_remove_group"); - - node=NULL; + get_ok()->set_text("Close"); } - GroupsEditor::~GroupsEditor() { } diff --git a/tools/editor/groups_editor.h b/tools/editor/groups_editor.h index 09883a150f..3a9cc77727 100644 --- a/tools/editor/groups_editor.h +++ b/tools/editor/groups_editor.h @@ -29,42 +29,42 @@ #ifndef GROUPS_EDITOR_H #define GROUPS_EDITOR_H - #include "scene/gui/dialogs.h" #include "scene/gui/button.h" #include "scene/gui/tree.h" #include "scene/gui/line_edit.h" #include "undo_redo.h" + /** @author Juan Linietsky <reduzio@gmail.com> */ -class GroupsEditor : public ConfirmationDialog { - - OBJ_TYPE( GroupsEditor, ConfirmationDialog ); - + +class GroupsEditor : public AcceptDialog { + + OBJ_TYPE(GroupsEditor,AcceptDialog); + + Node *node; + LineEdit *group_name; - Tree *tree; Button *add; - Button *remove; - Node *node; + Tree *tree; + UndoRedo *undo_redo; - + void update_tree(); - void _add(); - void _remove(); + void _add_group(const String& p_group=""); + void _remove_group(Object *p_item, int p_column, int p_id); void _close(); - protected: - - void _notification(int p_what); - static void _bind_methods(); + + static void _bind_methods(); public: - + void set_undo_redo(UndoRedo *p_undoredo) { undo_redo=p_undoredo; } void set_current(Node* p_node); - + GroupsEditor(); ~GroupsEditor(); - }; + #endif diff --git a/tools/editor/icons/icon_console.png b/tools/editor/icons/icon_console.png Binary files differnew file mode 100644 index 0000000000..7dc7407ef7 --- /dev/null +++ b/tools/editor/icons/icon_console.png diff --git a/tools/editor/icons/icon_key_invalid.png b/tools/editor/icons/icon_key_invalid.png Binary files differnew file mode 100644 index 0000000000..e8e6c87180 --- /dev/null +++ b/tools/editor/icons/icon_key_invalid.png diff --git a/tools/editor/icons/icon_key_invalid_hover.png b/tools/editor/icons/icon_key_invalid_hover.png Binary files differnew file mode 100644 index 0000000000..6f0396d96a --- /dev/null +++ b/tools/editor/icons/icon_key_invalid_hover.png diff --git a/tools/editor/io_plugins/editor_export_scene.cpp b/tools/editor/io_plugins/editor_export_scene.cpp new file mode 100644 index 0000000000..cd5c34e53b --- /dev/null +++ b/tools/editor/io_plugins/editor_export_scene.cpp @@ -0,0 +1,112 @@ +#include "editor_export_scene.h" +#include "io/resource_loader.h" +#include "io/resource_saver.h" +#include "os/dir_access.h" +#include "os/file_access.h" +#include "tools/editor/editor_settings.h" +#include "scene/resources/packed_scene.h" +#include "globals.h" + +Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { + + if (!EditorImportExport::get_singleton()->get_convert_text_scenes()) { + return Vector<uint8_t>(); + } + + + String extension = p_path.extension(); + + //step 1 check if scene + + if (extension=="xml" || extension=="xres") { + + String type = ResourceLoader::get_resource_type(p_path); + + if (type!="PackedScene") + return Vector<uint8_t>(); + + } else if (extension!="tscn" && extension!="xscn") { + return Vector<uint8_t>(); + } + + //step 2 check if cached + + uint64_t sd=0; + String smd5; + String gp = Globals::get_singleton()->globalize_path(p_path); + String md5=gp.md5_text(); + String tmp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/"); + + bool valid=false; + { + //if existing, make sure it's valid + FileAccessRef f = FileAccess::open(tmp_path+"scnexp-"+md5+".txt",FileAccess::READ); + if (f) { + + uint64_t d = f->get_line().strip_edges().to_int64(); + sd = FileAccess::get_modified_time(p_path); + + if (d==sd) { + valid=true; + } else { + String cmd5 = f->get_line().strip_edges(); + smd5 = FileAccess::get_md5(p_path); + if (cmd5==smd5) { + valid=true; + } + } + + + } + } + + if (!valid) { + //cache failed, convert + DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + + String copy = p_path+".convert."+extension; + + // a copy will allow loading the internal resources without conflicting with opened scenes + da->copy(p_path,copy); + + //@todo for tscn use something more efficient + + Ref<PackedScene> copyres = ResourceLoader::load(copy,"PackedScene"); + + da->remove(copy); + + memdelete(da); + + ERR_FAIL_COND_V(!copyres.is_valid(),Vector<uint8_t>()); + + Error err = ResourceSaver::save(tmp_path+"scnexp-"+md5+".scn",copyres); + + copyres=Ref<PackedScene>(); + + ERR_FAIL_COND_V(err!=OK,Vector<uint8_t>()); + + FileAccessRef f = FileAccess::open(tmp_path+"scnexp-"+md5+".txt",FileAccess::WRITE); + + if (sd==0) + sd = FileAccess::get_modified_time(p_path); + if (smd5==String()) + smd5 = FileAccess::get_md5(p_path); + + f->store_line(String::num(sd)); + f->store_line(smd5); + f->store_line(gp); //source path for reference + } + + + Vector<uint8_t> ret = FileAccess::get_file_as_array(tmp_path+"scnexp-"+md5+".scn"); + + p_path+=".optimized.scn"; + + return ret; + +} + + +EditorSceneExportPlugin::EditorSceneExportPlugin() +{ +} diff --git a/tools/editor/io_plugins/editor_export_scene.h b/tools/editor/io_plugins/editor_export_scene.h new file mode 100644 index 0000000000..134da6c234 --- /dev/null +++ b/tools/editor/io_plugins/editor_export_scene.h @@ -0,0 +1,16 @@ +#ifndef EDITOR_EXPORT_SCENE_H +#define EDITOR_EXPORT_SCENE_H + +#include "tools/editor/editor_import_export.h" + + +class EditorSceneExportPlugin : public EditorExportPlugin { + OBJ_TYPE( EditorSceneExportPlugin, EditorExportPlugin ); +public: + + virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform); + + EditorSceneExportPlugin(); +}; + +#endif // EDITOR_EXPORT_SCENE_H diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 10a3877529..5ba0669f1d 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -520,6 +520,10 @@ class EditorFontImportDialog : public ConfirmationDialog { return; } + if (dest->get_line_edit()->get_text().get_file()==".fnt") { + dest->get_line_edit()->set_text(dest->get_line_edit()->get_text().get_base_dir() + "/" + source->get_line_edit()->get_text().get_file().basename() + ".fnt" ); + } + Ref<ResourceImportMetadata> rimd = get_rimd(); if (rimd.is_null()) { diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp index 2139513025..b32ab8cb0b 100644 --- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp @@ -128,7 +128,7 @@ class EditorMeshImportDialog : public ConfirmationDialog { LineEdit *save_path; EditorFileDialog *file_select; EditorDirDialog *save_select; - ConfirmationDialog *error_dialog; + AcceptDialog *error_dialog; PropertyEditor *option_editor; _EditorMeshImportOptions *options; @@ -169,13 +169,12 @@ public: void _browse_target() { save_select->popup_centered_ratio(); - } - void popup_import(const String& p_path) { popup_centered(Size2(400,400)); + if (p_path!="") { Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path); @@ -199,14 +198,13 @@ public: } } - void _import() { Vector<String> meshes = import_path->get_text().split(","); - if (meshes.size()==0) { error_dialog->set_text("No meshes to import!"); - error_dialog->popup_centered(Size2(200,100)); + error_dialog->popup_centered_minsize(); + return; } for(int i=0;i<meshes.size();i++) { @@ -229,19 +227,18 @@ public: String dst = save_path->get_text(); if (dst=="") { error_dialog->set_text("Save path is empty!"); - error_dialog->popup_centered(Size2(200,100)); + error_dialog->popup_centered_minsize(); + return; } dst = dst.plus_file(meshes[i].get_file().basename()+".msh"); - Error err = plugin->import(dst,imd); + plugin->import(dst,imd); } hide(); - } - void _notification(int p_what) { @@ -253,27 +250,24 @@ public: static void _bind_methods() { - ObjectTypeDB::bind_method("_choose_files",&EditorMeshImportDialog::_choose_files); ObjectTypeDB::bind_method("_choose_save_dir",&EditorMeshImportDialog::_choose_save_dir); ObjectTypeDB::bind_method("_import",&EditorMeshImportDialog::_import); ObjectTypeDB::bind_method("_browse",&EditorMeshImportDialog::_browse); ObjectTypeDB::bind_method("_browse_target",&EditorMeshImportDialog::_browse_target); - // ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) ); } EditorMeshImportDialog(EditorMeshImportPlugin *p_plugin) { plugin=p_plugin; - set_title("Single Mesh Import"); + set_hide_on_ok(false); VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); - HBoxContainer *hbc = memnew( HBoxContainer ); vbc->add_margin_child("Source Mesh(es):",hbc); @@ -300,28 +294,23 @@ public: save_choose->connect("pressed", this,"_browse_target"); - file_select = memnew(EditorFileDialog); + file_select = memnew( EditorFileDialog ); file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - add_child(file_select); file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); - file_select->connect("files_selected", this,"_choose_files"); file_select->add_filter("*.obj ; Wavefront OBJ"); - save_select = memnew( EditorDirDialog ); - add_child(save_select); + add_child(file_select); + file_select->connect("files_selected", this,"_choose_files"); - // save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR); + save_select = memnew( EditorDirDialog ); + add_child(save_select); save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); get_ok()->set_text("Import"); - - error_dialog = memnew ( ConfirmationDialog ); + error_dialog = memnew( AcceptDialog ); add_child(error_dialog); - error_dialog->get_ok()->set_text("Accept"); - // error_dialog->get_cancel()->hide(); - set_hide_on_ok(false); options = memnew( _EditorMeshImportOptions ); option_editor = memnew( PropertyEditor ); diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index 6542fc8b4a..dc2c241d2f 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -1250,8 +1250,15 @@ void AnimationPlayerEditor::_bind_methods() { } +AnimationPlayerEditor *AnimationPlayerEditor::singleton=NULL; + +AnimationPlayer *AnimationPlayerEditor::get_player() const { + + return player; +} AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { editor=p_editor; + singleton=this; updating=false; diff --git a/tools/editor/plugins/animation_player_editor_plugin.h b/tools/editor/plugins/animation_player_editor_plugin.h index ac4d1ab6ba..839df3ddcc 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.h +++ b/tools/editor/plugins/animation_player_editor_plugin.h @@ -162,6 +162,7 @@ class AnimationPlayerEditor : public VBoxContainer { void _animation_tool_menu(int p_option); void _animation_save_menu(int p_option); + AnimationPlayerEditor(); protected: @@ -171,6 +172,9 @@ protected: static void _bind_methods(); public: + AnimationPlayer *get_player() const; + static AnimationPlayerEditor *singleton; + Dictionary get_state() const; void set_state(const Dictionary& p_state); diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index e3f4edf967..a3164fc524 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -423,8 +423,6 @@ CanvasItem* CanvasItemEditor::_select_canvas_item_at_pos(const Point2& p_pos,Nod r=_select_canvas_item_at_pos(p_pos,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform); else { CanvasLayer *cl = p_node->cast_to<CanvasLayer>(); - if (cl) - return NULL; r=_select_canvas_item_at_pos(p_pos,p_node->get_child(i),transform ,cl ? cl->get_transform() : p_canvas_xform); //use base transform } @@ -433,7 +431,7 @@ CanvasItem* CanvasItemEditor::_select_canvas_item_at_pos(const Point2& p_pos,Nod } - if (c && c->is_visible() && !c->has_meta("_edit_lock_")) { + if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) { Rect2 rect = c->get_item_rect(); Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos); @@ -461,14 +459,12 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos,Node* p_nod _find_canvas_items_at_pos(p_pos,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform, r_items); else { CanvasLayer *cl = p_node->cast_to<CanvasLayer>(); - if (cl) - return; _find_canvas_items_at_pos(p_pos,p_node->get_child(i),transform ,cl ? cl->get_transform() : p_canvas_xform, r_items); //use base transform } } - if (c && c->is_visible() && !c->has_meta("_edit_lock_")) { + if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) { Rect2 rect = c->get_item_rect(); Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos); @@ -505,14 +501,12 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2& p_rect,Node* p_no _find_canvas_items_at_rect(p_rect,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform,r_items); else { CanvasLayer *cl = p_node->cast_to<CanvasLayer>(); - if (cl) - return; _find_canvas_items_at_rect(p_rect,p_node->get_child(i),transform,cl?cl->get_transform():p_canvas_xform,r_items); } } - if (c && c->is_visible() && !c->has_meta("_edit_lock_")) { + if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) { Rect2 rect = c->get_item_rect(); Matrix32 xform = p_parent_xform * p_canvas_xform * c->get_transform(); diff --git a/tools/editor/plugins/item_list_editor_plugin.cpp b/tools/editor/plugins/item_list_editor_plugin.cpp index fa261edea3..9c53c73afd 100644 --- a/tools/editor/plugins/item_list_editor_plugin.cpp +++ b/tools/editor/plugins/item_list_editor_plugin.cpp @@ -30,7 +30,6 @@ #include "io/resource_loader.h" - bool ItemListPlugin::_set(const StringName& p_name, const Variant& p_value) { String name = p_name; @@ -45,12 +44,10 @@ bool ItemListPlugin::_set(const StringName& p_name, const Variant& p_value) { set_item_checkable(idx,p_value); else if (what=="checked") set_item_checked(idx,p_value); - else if (what=="enabled") - set_item_enabled(idx,p_value); - else if (what=="accel") - set_item_accel(idx,p_value); else if (what=="id") set_item_id(idx,p_value); + else if (what=="enabled") + set_item_enabled(idx,p_value); else if (what=="separator") set_item_separator(idx,p_value); else @@ -60,6 +57,7 @@ bool ItemListPlugin::_set(const StringName& p_name, const Variant& p_value) { } bool ItemListPlugin::_get(const StringName& p_name,Variant &r_ret) const { + String name = p_name; int idx = name.get_slice("/",0).to_int(); String what=name.get_slice("/",1); @@ -72,12 +70,10 @@ bool ItemListPlugin::_get(const StringName& p_name,Variant &r_ret) const { r_ret=is_item_checkable(idx); else if (what=="checked") r_ret=is_item_checked(idx); - else if (what=="enabled") - r_ret=is_item_enabled(idx); - else if (what=="accel") - r_ret=get_item_accel(idx); else if (what=="id") r_ret=get_item_id(idx); + else if (what=="enabled") + r_ret=is_item_enabled(idx); else if (what=="separator") r_ret=is_item_separator(idx); else @@ -93,66 +89,119 @@ void ItemListPlugin::_get_property_list( List<PropertyInfo> *p_list) const { p_list->push_back( PropertyInfo(Variant::STRING,base+"text") ); p_list->push_back( PropertyInfo(Variant::OBJECT,base+"icon",PROPERTY_HINT_RESOURCE_TYPE,"Texture") ); - if (get_flags()&FLAG_CHECKABLE) { + int flags = get_flags(); + + if (flags&FLAG_CHECKABLE) { p_list->push_back( PropertyInfo(Variant::BOOL,base+"checkable") ); p_list->push_back( PropertyInfo(Variant::BOOL,base+"checked") ); - } - if (get_flags()&FLAG_ENABLE) { + if (flags&FLAG_ID) + p_list->push_back( PropertyInfo(Variant::INT,base+"id",PROPERTY_HINT_RANGE,"-1,4096") ); + + if (flags&FLAG_ENABLE) p_list->push_back( PropertyInfo(Variant::BOOL,base+"enabled") ); - } - if (get_flags()&FLAG_ACCEL) { + if (flags&FLAG_SEPARATOR) + p_list->push_back( PropertyInfo(Variant::BOOL,base+"separator") ); + } +} - p_list->push_back( PropertyInfo(Variant::INT,base+"accel",PROPERTY_HINT_KEY_ACCEL) ); +/////////////////////////////////////////////////////////////// +///////////////////////// PLUGINS ///////////////////////////// +/////////////////////////////////////////////////////////////// - } - if (get_flags()&FLAG_ID) { +void ItemListOptionButtonPlugin::set_object(Object *p_object) { - p_list->push_back( PropertyInfo(Variant::INT,base+"id",PROPERTY_HINT_RANGE,"-1,4096") ); + ob = p_object->cast_to<OptionButton>(); +} - } - if (get_flags()&FLAG_SEPARATOR) { +bool ItemListOptionButtonPlugin::handles(Object *p_object) const { - p_list->push_back( PropertyInfo(Variant::BOOL,base+"separator") ); + return p_object->is_type("OptionButton"); +} - } - } +int ItemListOptionButtonPlugin::get_flags() const { + + return FLAG_ICON|FLAG_ID|FLAG_ENABLE; } -void ItemListEditor::_node_removed(Node *p_node) { +void ItemListOptionButtonPlugin::add_item() { - if(p_node==item_list) { - item_list=NULL; - hide(); - dialog->hide(); - } + ob->add_item( "Item "+itos(ob->get_item_count())); + _change_notify(); +} +int ItemListOptionButtonPlugin::get_item_count() const { + return ob->get_item_count(); } -void ItemListEditor::_delete_pressed() { +void ItemListOptionButtonPlugin::erase(int p_idx) { - String p = prop_editor->get_selected_path(); + ob->remove_item(p_idx); + _change_notify(); +} - if (p.find("/")!=-1) { +ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() { - if (selected_idx<0 || selected_idx>=item_plugins.size()) - return; + ob=NULL; +} - item_plugins[selected_idx]->erase(p.get_slice("/",0).to_int());; - } +/////////////////////////////////////////////////////////////// + +void ItemListPopupMenuPlugin::set_object(Object *p_object) { + if (p_object->is_type("MenuButton")) + pp = p_object->cast_to<MenuButton>()->get_popup(); + else + pp = p_object->cast_to<PopupMenu>(); } -void ItemListEditor::_add_pressed() { +bool ItemListPopupMenuPlugin::handles(Object *p_object) const { - if (selected_idx<0 || selected_idx>=item_plugins.size()) - return; + return p_object->is_type("PopupMenu") || p_object->is_type("MenuButton"); +} - item_plugins[selected_idx]->add_item(); +int ItemListPopupMenuPlugin::get_flags() const { + + return FLAG_ICON|FLAG_CHECKABLE|FLAG_ID|FLAG_ENABLE|FLAG_SEPARATOR; +} + +void ItemListPopupMenuPlugin::add_item() { + + pp->add_item( "Item "+itos(pp->get_item_count())); + _change_notify(); +} + +int ItemListPopupMenuPlugin::get_item_count() const { + + return pp->get_item_count(); +} + +void ItemListPopupMenuPlugin::erase(int p_idx) { + + pp->remove_item(p_idx); + _change_notify(); +} + +ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() { + + pp=NULL; +} + +/////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////// + +void ItemListEditor::_node_removed(Node *p_node) { + + if(p_node==item_list) { + item_list=NULL; + hide(); + dialog->hide(); + } } void ItemListEditor::_notification(int p_notification) { @@ -160,57 +209,73 @@ void ItemListEditor::_notification(int p_notification) { if (p_notification==NOTIFICATION_ENTER_TREE) { add_button->set_icon(get_icon("Add","EditorIcons")); - del_button->set_icon(get_icon("Del","EditorIcons")); + del_button->set_icon(get_icon("Remove","EditorIcons")); } } +void ItemListEditor::_add_pressed() { -void ItemListEditor::_menu_option(int p_option) { + if (selected_idx==-1) + return; + item_plugins[selected_idx]->add_item(); +} - switch(p_option) { +void ItemListEditor::_delete_pressed() { - case MENU_EDIT_ITEMS: { + TreeItem *ti = tree->get_selected(); - dialog->popup_centered_ratio(); - } break; - } + if (!ti) + return; + + if (ti->get_parent()!=tree->get_root()) + return; + + int idx = ti->get_text(0).to_int(); + + if (selected_idx==-1) + return; + + item_plugins[selected_idx]->erase(idx); } +void ItemListEditor::_edit_items() { + + dialog->popup_centered(Vector2(300, 400)); +} void ItemListEditor::edit(Node *p_item_list) { item_list=p_item_list; + if (!item_list) { + selected_idx=-1; + property_editor->edit(NULL); + return; + } + for(int i=0;i<item_plugins.size();i++) { if (item_plugins[i]->handles(p_item_list)) { item_plugins[i]->set_object(p_item_list); - prop_editor->edit(item_plugins[i]); + property_editor->edit(item_plugins[i]); + + if (has_icon(item_list->get_type(), "EditorIcons")) + toolbar_button->set_icon(get_icon(item_list->get_type(), "EditorIcons")); + else + toolbar_button->set_icon(Ref<Texture>()); + selected_idx=i; return; } } selected_idx=-1; - - prop_editor->edit(NULL); - -} - - -void ItemListEditor::_bind_methods() { - - ObjectTypeDB::bind_method("_menu_option",&ItemListEditor::_menu_option); - ObjectTypeDB::bind_method("_add_button",&ItemListEditor::_add_pressed); - ObjectTypeDB::bind_method("_delete_button",&ItemListEditor::_delete_pressed); - - //ObjectTypeDB::bind_method("_populate",&ItemListEditor::_populate); - + property_editor->edit(NULL); } bool ItemListEditor::handles(Object *p_object) const { - return false; + for(int i=0;i<item_plugins.size();i++) { if (item_plugins[i]->handles(p_object)) { return true; @@ -218,57 +283,65 @@ bool ItemListEditor::handles(Object *p_object) const { } return false; +} +void ItemListEditor::_bind_methods() { + + ObjectTypeDB::bind_method("_edit_items",&ItemListEditor::_edit_items); + ObjectTypeDB::bind_method("_add_button",&ItemListEditor::_add_pressed); + ObjectTypeDB::bind_method("_delete_button",&ItemListEditor::_delete_pressed); } + ItemListEditor::ItemListEditor() { selected_idx=-1; - options = memnew( MenuButton ); - add_child(options); - options->set_area_as_parent_rect(); - options->set_text("Items"); - options->get_popup()->add_item("Edit Items",MENU_EDIT_ITEMS); - //options->get_popup()->add_item("Clear",MENU_CLEAR); + add_child( memnew( VSeparator ) ); - options->get_popup()->connect("item_pressed", this,"_menu_option"); + toolbar_button = memnew( ToolButton ); + toolbar_button->set_text("Items"); + add_child(toolbar_button); + toolbar_button->connect("pressed",this,"_edit_items"); dialog = memnew( AcceptDialog ); + dialog->set_title("Item List Editor"); add_child( dialog ); - + VBoxContainer *vbc = memnew( VBoxContainer ); + dialog->add_child(vbc); + dialog->set_child_rect(vbc); HBoxContainer *hbc = memnew( HBoxContainer ); - - dialog->add_child(hbc); - dialog->set_child_rect(hbc); - - prop_editor = memnew( PropertyEditor ); - - hbc->add_child(prop_editor); - prop_editor->set_h_size_flags(SIZE_EXPAND_FILL); - - VBoxContainer *vbc = memnew( VBoxContainer ); - hbc->add_child(vbc); + hbc->set_h_size_flags(SIZE_EXPAND_FILL); + vbc->add_child(hbc); add_button = memnew( Button ); - //add_button->set_text("Add"); + add_button->set_text("Add"); + hbc->add_child(add_button); add_button->connect("pressed",this,"_add_button"); - vbc->add_child(add_button); + + hbc->add_spacer(); del_button = memnew( Button ); - //del_button->set_text("Del"); + del_button->set_text("Delete"); + hbc->add_child(del_button); del_button->connect("pressed",this,"_delete_button"); - vbc->add_child(del_button); - dialog->set_title("Item List"); - prop_editor->hide_top_label(); + property_editor = memnew( PropertyEditor ); + property_editor->hide_top_label(); + property_editor->set_subsection_selectable(true); + vbc->add_child(property_editor); + property_editor->set_v_size_flags(SIZE_EXPAND_FILL); + tree = property_editor->get_scene_tree(); +} +ItemListEditor::~ItemListEditor() { + for(int i=0;i<item_plugins.size();i++) + memdelete( item_plugins[i] ); } - void ItemListEditorPlugin::edit(Object *p_object) { item_list_editor->edit(p_object->cast_to<Node>()); @@ -288,127 +361,19 @@ void ItemListEditorPlugin::make_visible(bool p_visible) { item_list_editor->hide(); item_list_editor->edit(NULL); } - -} - - -ItemListEditor::~ItemListEditor() { - - for(int i=0;i<item_plugins.size();i++) - memdelete( item_plugins[i] ); } -///////////////////////// PLUGINS ///////////////////////////// -///////////////////////// PLUGINS ///////////////////////////// -///////////////////////// PLUGINS ///////////////////////////// -///////////////////////// PLUGINS ///////////////////////////// -///////////////////////// PLUGINS ///////////////////////////// - - -class ItemListOptionButtonPlugin : public ItemListPlugin { - - OBJ_TYPE(ItemListOptionButtonPlugin,ItemListPlugin); - - OptionButton *ob; -public: - - virtual void set_object(Object *p_object) { ob = p_object->cast_to<OptionButton>(); } - - virtual bool handles(Object *p_object) const { return p_object->cast_to<OptionButton>()!=NULL; } - - virtual int get_flags() const { return FLAG_ICON|FLAG_ID|FLAG_ENABLE; } - - virtual void set_item_text(int p_idx,const String& p_text){ ob->set_item_text(p_idx,p_text);} - virtual void set_item_icon(int p_idx,const Ref<Texture>& p_tex){ ob->set_item_icon(p_idx,p_tex);} - virtual void set_item_enabled(int p_idx,int p_enabled){ ob->set_item_disabled(p_idx,!p_enabled);} - virtual void set_item_id(int p_idx,int p_id){ ob->set_item_ID(p_idx,p_id);} - - - virtual String get_item_text(int p_idx) const{ return ob->get_item_text(p_idx); }; - virtual Ref<Texture> get_item_icon(int p_idx) const{ return ob->get_item_icon(p_idx); }; - virtual bool is_item_enabled(int p_idx) const{ return !ob->is_item_disabled(p_idx); }; - virtual int get_item_id(int p_idx) const{ return ob->get_item_ID(p_idx); }; - - virtual void add_item() { ob->add_item( "New Item "+itos(ob->get_item_count())); _change_notify();} - virtual int get_item_count() const { return ob->get_item_count(); } - virtual void erase(int p_idx) { ob->remove_item(p_idx); _change_notify();} - - - ItemListOptionButtonPlugin() { ob=NULL; } -}; - -class ItemListPopupMenuPlugin : public ItemListPlugin { - - OBJ_TYPE(ItemListPopupMenuPlugin,ItemListPlugin); - - PopupMenu *pp; -public: - - virtual void set_object(Object *p_object) { - if (p_object->cast_to<MenuButton>()) - pp = p_object->cast_to<MenuButton>()->get_popup(); - else - pp = p_object->cast_to<PopupMenu>(); - } - - virtual bool handles(Object *p_object) const { return p_object->cast_to<PopupMenu>()!=NULL || p_object->cast_to<MenuButton>()!=NULL; } - - virtual int get_flags() const { return FLAG_ICON|FLAG_ID|FLAG_ENABLE|FLAG_CHECKABLE|FLAG_SEPARATOR|FLAG_ACCEL; } - - virtual void set_item_text(int p_idx,const String& p_text){ pp->set_item_text(p_idx,p_text); } - virtual void set_item_icon(int p_idx,const Ref<Texture>& p_tex){ pp->set_item_icon(p_idx,p_tex);} - virtual void set_item_checkable(int p_idx,bool p_check){ pp->set_item_as_checkable(p_idx,p_check);} - virtual void set_item_checked(int p_idx,bool p_checked){ pp->set_item_checked(p_idx,p_checked);} - virtual void set_item_accel(int p_idx,int p_accel){ pp->set_item_accelerator(p_idx,p_accel);} - virtual void set_item_enabled(int p_idx,int p_enabled){ pp->set_item_disabled(p_idx,!p_enabled);} - virtual void set_item_id(int p_idx,int p_id){ pp->set_item_ID(p_idx,p_idx);} - virtual void set_item_separator(int p_idx,bool p_separator){ pp->set_item_as_separator(p_idx,p_separator);} - - - virtual String get_item_text(int p_idx) const{ return pp->get_item_text(p_idx); }; - virtual Ref<Texture> get_item_icon(int p_idx) const{ return pp->get_item_icon(p_idx); }; - virtual bool is_item_checkable(int p_idx) const{ return pp->is_item_checkable(p_idx); }; - virtual bool is_item_checked(int p_idx) const{ return pp->is_item_checked(p_idx); }; - virtual int get_item_accel(int p_idx) const{ return pp->get_item_accelerator(p_idx); }; - virtual bool is_item_enabled(int p_idx) const{ return !pp->is_item_disabled(p_idx); }; - virtual int get_item_id(int p_idx) const{ return pp->get_item_ID(p_idx); }; - virtual bool is_item_separator(int p_idx) const{ return pp->is_item_separator(p_idx); }; - - - - virtual void add_item() { pp->add_item( "New Item "+itos(pp->get_item_count())); _change_notify();} - virtual int get_item_count() const { return pp->get_item_count(); } - virtual void erase(int p_idx) { pp->remove_item(p_idx); _change_notify();} - - - ItemListPopupMenuPlugin() { pp=NULL; } -}; - - - - - - ItemListEditorPlugin::ItemListEditorPlugin(EditorNode *p_node) { editor=p_node; item_list_editor = memnew( ItemListEditor ); - editor->get_viewport()->add_child(item_list_editor); - -// item_list_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END); -// item_list_editor->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); - item_list_editor->set_margin(MARGIN_LEFT,180); - item_list_editor->set_margin(MARGIN_RIGHT,230); - item_list_editor->set_margin(MARGIN_TOP,0); - item_list_editor->set_margin(MARGIN_BOTTOM,10); - + CanvasItemEditor::get_singleton()->add_control_to_menu_panel(item_list_editor); item_list_editor->hide(); - item_list_editor->add_plugin( memnew( ItemListOptionButtonPlugin) ); - item_list_editor->add_plugin( memnew( ItemListPopupMenuPlugin) ); + item_list_editor->add_plugin( memnew( ItemListOptionButtonPlugin ) ); + item_list_editor->add_plugin( memnew( ItemListPopupMenuPlugin ) ); } - ItemListEditorPlugin::~ItemListEditorPlugin() { } diff --git a/tools/editor/plugins/item_list_editor_plugin.h b/tools/editor/plugins/item_list_editor_plugin.h index 351dbb800d..b40a2c22f8 100644 --- a/tools/editor/plugins/item_list_editor_plugin.h +++ b/tools/editor/plugins/item_list_editor_plugin.h @@ -31,10 +31,11 @@ #include "tools/editor/editor_plugin.h" #include "tools/editor/editor_node.h" +#include "canvas_item_editor_plugin.h" + #include "scene/gui/option_button.h" #include "scene/gui/menu_button.h" #include "scene/gui/popup_menu.h" -#include "scene/gui/spin_box.h" /** @author Juan Linietsky <reduzio@gmail.com> @@ -51,43 +52,42 @@ protected: bool _get(const StringName& p_name,Variant &r_ret) const; void _get_property_list( List<PropertyInfo> *p_list) const; - public: enum Flags { FLAG_ICON=1, FLAG_CHECKABLE=2, - FLAG_ACCEL=4, - FLAG_ID=8, - FLAG_ENABLE=16, - FLAG_SEPARATOR=32 + FLAG_ID=4, + FLAG_ENABLE=8, + FLAG_SEPARATOR=16 }; virtual void set_object(Object *p_object)=0; - virtual bool handles(Object *p_object) const=0; virtual int get_flags() const=0; - virtual void set_item_text(int p_idx,const String& p_text){} - virtual void set_item_icon(int p_idx,const Ref<Texture>& p_tex){} - virtual void set_item_checkable(int p_idx,bool p_check){} - virtual void set_item_checked(int p_idx,bool p_checked){} - virtual void set_item_accel(int p_idx,int p_accel){} - virtual void set_item_enabled(int p_idx,int p_enabled){} - virtual void set_item_id(int p_idx,int p_id){} - virtual void set_item_separator(int p_idx,bool p_separator){} - - + virtual void set_item_text(int p_idx, const String& p_text) {} virtual String get_item_text(int p_idx) const{ return ""; }; + + virtual void set_item_icon(int p_idx, const Ref<Texture>& p_tex) {} virtual Ref<Texture> get_item_icon(int p_idx) const{ return Ref<Texture>(); }; + + virtual void set_item_checkable(int p_idx, bool p_check) {} virtual bool is_item_checkable(int p_idx) const{ return false; }; + + virtual void set_item_checked(int p_idx, bool p_checked) {} virtual bool is_item_checked(int p_idx) const{ return false; }; - virtual int get_item_accel(int p_idx) const{ return 0; }; + + virtual void set_item_enabled(int p_idx, int p_enabled) {} virtual bool is_item_enabled(int p_idx) const{ return false; }; + + virtual void set_item_id(int p_idx, int p_id) {} virtual int get_item_id(int p_idx) const{ return -1; }; - virtual bool is_item_separator(int p_idx) const{ return false; }; + + virtual void set_item_separator(int p_idx, bool p_separator) {} + virtual bool is_item_separator(int p_idx) const { return false; }; virtual void add_item()=0; virtual int get_item_count() const=0; @@ -96,41 +96,107 @@ public: ItemListPlugin() {} }; -class ItemListEditor : public Control { +/////////////////////////////////////////////////////////////// - OBJ_TYPE(ItemListEditor, Control ); +class ItemListOptionButtonPlugin : public ItemListPlugin { - Node *item_list; + OBJ_TYPE(ItemListOptionButtonPlugin,ItemListPlugin); - enum { + OptionButton *ob; +public: - MENU_EDIT_ITEMS, - MENU_CLEAR - }; + virtual void set_object(Object *p_object); + virtual bool handles(Object *p_object) const; + virtual int get_flags() const; - AcceptDialog *dialog; + virtual void set_item_text(int p_idx, const String& p_text) { ob->set_item_text(p_idx,p_text); } + virtual String get_item_text(int p_idx) const { return ob->get_item_text(p_idx); } - PropertyEditor *prop_editor; + virtual void set_item_icon(int p_idx, const Ref<Texture>& p_tex) { ob->set_item_icon(p_idx, p_tex); } + virtual Ref<Texture> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); } - MenuButton * options; - int selected_idx; + virtual void set_item_enabled(int p_idx, int p_enabled) { ob->set_item_disabled(p_idx, !p_enabled); } + virtual bool is_item_enabled(int p_idx) const { return !ob->is_item_disabled(p_idx); } + + virtual void set_item_id(int p_idx, int p_id) { ob->set_item_ID(p_idx,p_id); } + virtual int get_item_id(int p_idx) const { return ob->get_item_ID(p_idx); } + + virtual void add_item(); + virtual int get_item_count() const; + virtual void erase(int p_idx); + + ItemListOptionButtonPlugin(); +}; + +class ItemListPopupMenuPlugin : public ItemListPlugin { + + OBJ_TYPE(ItemListPopupMenuPlugin,ItemListPlugin); + + PopupMenu *pp; +public: + + virtual void set_object(Object *p_object); + virtual bool handles(Object *p_object) const; + virtual int get_flags() const; + virtual void set_item_text(int p_idx, const String& p_text) { pp->set_item_text(p_idx,p_text); } + virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); } + + virtual void set_item_icon(int p_idx, const Ref<Texture>& p_tex) { pp->set_item_icon(p_idx,p_tex); } + virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); } + + virtual void set_item_checkable(int p_idx, bool p_check) { pp->set_item_as_checkable(p_idx,p_check); } + virtual bool is_item_checkable(int p_idx) const { return pp->is_item_checkable(p_idx); } + + virtual void set_item_checked(int p_idx, bool p_checked) { pp->set_item_checked(p_idx,p_checked); } + virtual bool is_item_checked(int p_idx) const { return pp->is_item_checked(p_idx); } + + virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx,!p_enabled); } + virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); } + + virtual void set_item_id(int p_idx, int p_id) { pp->set_item_ID(p_idx,p_idx); } + virtual int get_item_id(int p_idx) const { return pp->get_item_ID(p_idx); } + + virtual void set_item_separator(int p_idx, bool p_separator) { pp->set_item_as_separator(p_idx,p_separator); } + virtual bool is_item_separator(int p_idx) const { return pp->is_item_separator(p_idx); } + + virtual void add_item(); + virtual int get_item_count() const; + virtual void erase(int p_idx); + + ItemListPopupMenuPlugin(); +}; + +/////////////////////////////////////////////////////////////// + +class ItemListEditor : public HBoxContainer { + + OBJ_TYPE(ItemListEditor,HBoxContainer); + + Node *item_list; + + ToolButton *toolbar_button; + + AcceptDialog *dialog; + PropertyEditor *property_editor; + Tree *tree; Button *add_button; Button *del_button; - -// FileDialog *emission_file_dialog; - void _menu_option(int); + int selected_idx; Vector<ItemListPlugin*> item_plugins; - void _node_removed(Node *p_node); + void _edit_items(); + void _add_pressed(); void _delete_pressed(); + + void _node_removed(Node *p_node); + protected: void _notification(int p_notification); - static void _bind_methods(); public: @@ -143,7 +209,7 @@ public: class ItemListEditorPlugin : public EditorPlugin { - OBJ_TYPE( ItemListEditorPlugin, EditorPlugin ); + OBJ_TYPE(ItemListEditorPlugin,EditorPlugin); ItemListEditor *item_list_editor; EditorNode *editor; diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 65ed420a51..37f4076a0c 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -379,6 +379,8 @@ void ScriptTextEditor::reload_text() { te->set_h_scroll(h); te->set_v_scroll(v); + te->tag_saved_version(); + _line_col_changed(); } @@ -391,6 +393,12 @@ void ScriptTextEditor::_notification(int p_what) { } } + +bool ScriptTextEditor::is_unsaved() { + + return get_text_edit()->get_version()!=get_text_edit()->get_saved_version(); +} + String ScriptTextEditor::get_name() { String name; @@ -492,6 +500,59 @@ static Node* _find_node_for_script(Node* p_base, Node*p_current, const Ref<Scrip return NULL; } +static void _find_changed_scripts_for_external_editor(Node* p_base, Node*p_current, Set<Ref<Script> > &r_scripts) { + + if (p_current->get_owner()!=p_base && p_base!=p_current) + return; + Ref<Script> c = p_current->get_script(); + + if (c.is_valid()) + r_scripts.insert(c); + + for(int i=0;i<p_current->get_child_count();i++) { + _find_changed_scripts_for_external_editor(p_base,p_current->get_child(i),r_scripts); + } + +} + +void ScriptEditor::_update_modified_scripts_for_external_editor() { + + if (!bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor"))) + return; + + Set<Ref<Script> > scripts; + + Node *base = get_tree()->get_edited_scene_root(); + if (base) { + _find_changed_scripts_for_external_editor(base,base,scripts); + } + + for (Set<Ref<Script> >::Element *E=scripts.front();E;E=E->next()) { + + Ref<Script> script = E->get(); + + if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) { + + continue; //internal script, who cares, though weird + } + + uint64_t last_date = script->get_last_modified_time(); + uint64_t date = FileAccess::get_modified_time(script->get_path()); + + if (last_date!=date) { + + Ref<Script> rel_script = ResourceLoader::load(script->get_path(),script->get_type(),true); + ERR_CONTINUE(!rel_script.is_valid()); + script->set_source_code( rel_script->get_source_code() ); + script->set_last_modified_time( rel_script->get_last_modified_time() ); + script->update_exports(); + } + + } +} + + + void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>* r_options) { Node *base = get_tree()->get_edited_scene_root(); @@ -749,6 +810,7 @@ void ScriptEditor::_reload_scripts(){ } disk_changed->hide(); + _update_script_names(); } @@ -791,46 +853,53 @@ bool ScriptEditor::_test_script_times_on_disk() { TreeItem *r = disk_changed_list->create_item(); disk_changed_list->set_hide_root(true); - bool all_ok=true; + bool need_ask=false; + bool need_reload=false; + bool use_autoreload=bool(EDITOR_DEF("text_editor/auto_reload_scripts_on_external_change",false)); + for(int i=0;i<tab_container->get_child_count();i++) { ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); - if (!ste) - continue; + if (ste) { + Ref<Script> script = ste->get_edited_script(); - Ref<Script> script = ste->get_edited_script(); + if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) + continue; //internal script, who cares - if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) - continue; //internal script, who cares + uint64_t last_date = script->get_last_modified_time(); + uint64_t date = FileAccess::get_modified_time(script->get_path()); - uint64_t last_date = script->get_last_modified_time(); - uint64_t date = FileAccess::get_modified_time(script->get_path()); + //printf("last date: %lli vs date: %lli\n",last_date,date); + if (last_date!=date) { - //printf("last date: %lli vs date: %lli\n",last_date,date); - if (last_date!=date) { + TreeItem *ti = disk_changed_list->create_item(r); + ti->set_text(0,script->get_path().get_file()); - TreeItem *ti = disk_changed_list->create_item(r); - ti->set_text(0,script->get_path().get_file()); - all_ok=false; - //r->set_metadata(0,); + if (!use_autoreload || ste->is_unsaved()) { + need_ask=true; + } + need_reload=true; + //r->set_metadata(0,); + } } } - if (!all_ok) { - if (bool(EDITOR_DEF("text_editor/auto_reload_changed_scripts",false))) { + if (need_reload) { + if (!need_ask) { script_editor->_reload_scripts(); + need_reload=false; } else { disk_changed->call_deferred("popup_centered_ratio",0.5); } } - return all_ok; + return need_reload; } void ScriptEditor::swap_lines(TextEdit *tx, int line1, int line2) @@ -881,18 +950,17 @@ void ScriptEditor::_menu_option(int p_option) { } break; case SEARCH_HELP: { - help_search_dialog->popup("current"); + help_search_dialog->popup(); } break; case SEARCH_CLASSES: { - if (tab_container->get_tab_count()==0) - break; - String current; - EditorHelp *eh = tab_container->get_child( tab_container->get_current_tab() )->cast_to<EditorHelp>(); - if (eh) { - current=eh->get_class_name(); + if (tab_container->get_tab_count()>0) { + EditorHelp *eh = tab_container->get_child( tab_container->get_current_tab() )->cast_to<EditorHelp>(); + if (eh) { + current=eh->get_class_name(); + } } help_index->popup_centered_ratio(0.6); @@ -1138,12 +1206,14 @@ void ScriptEditor::_menu_option(int p_option) { return; int line = tx->cursor_get_line(); int next_line = line + 1; + int column = tx->cursor_get_column(); - if (line == tx->get_line_count() || next_line > tx->get_line_count()) - return; + if (line >= tx->get_line_count() - 1) + tx->set_line(line, tx->get_line(line) + "\n"); String line_clone = tx->get_line(line); tx->insert_at(line_clone, next_line); + tx->cursor_set_column(column); tx->update(); } break; @@ -1388,6 +1458,7 @@ void ScriptEditor::_notification(int p_what) { if (p_what==NOTIFICATION_READY) { get_tree()->connect("tree_changed",this,"_tree_changed"); + editor->connect("request_help",this,"_request_help"); } if (p_what==NOTIFICATION_EXIT_TREE) { @@ -1401,6 +1472,7 @@ void ScriptEditor::_notification(int p_what) { if (p_what==MainLoop::NOTIFICATION_WM_FOCUS_IN) { _test_script_times_on_disk(); + _update_modified_scripts_for_external_editor(); } if (p_what==NOTIFICATION_PROCESS) { @@ -1409,6 +1481,11 @@ void ScriptEditor::_notification(int p_what) { } +void ScriptEditor::edited_scene_changed() { + + _update_modified_scripts_for_external_editor(); + +} static const Node * _find_node_with_script(const Node* p_node, const RefPtr & p_script) { @@ -1835,6 +1912,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { ScriptTextEditor *ste = memnew( ScriptTextEditor ); ste->set_edited_script(p_script); ste->get_text_edit()->set_tooltip_request_func(this,"_get_debug_tooltip",ste); + ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); tab_container->add_child(ste); _go_to_tab(tab_container->get_tab_count()-1); @@ -2205,6 +2283,7 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_script_split_dragged",&ScriptEditor::_script_split_dragged); ObjectTypeDB::bind_method("_help_class_open",&ScriptEditor::_help_class_open); ObjectTypeDB::bind_method("_help_class_goto",&ScriptEditor::_help_class_goto); + ObjectTypeDB::bind_method("_request_help",&ScriptEditor::_help_class_open); ObjectTypeDB::bind_method("_history_forward",&ScriptEditor::_history_forward); ObjectTypeDB::bind_method("_history_back",&ScriptEditor::_history_back); } @@ -2556,6 +2635,11 @@ void ScriptEditorPlugin::get_breakpoints(List<String> *p_breakpoints) { return script_editor->get_breakpoints(p_breakpoints); } +void ScriptEditorPlugin::edited_scene_changed() { + + script_editor->edited_scene_changed(); +} + ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { editor=p_node; @@ -2565,7 +2649,7 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { script_editor->hide(); - EDITOR_DEF("text_editor/auto_reload_changed_scripts",false); + EDITOR_DEF("text_editor/auto_reload_scripts_on_external_change",true); EDITOR_DEF("text_editor/open_dominant_script_on_scene_change",true); EDITOR_DEF("external_editor/use_external_editor",false); EDITOR_DEF("external_editor/exec_path",""); diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index e755f570ef..7875b4d144 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -103,7 +103,7 @@ public: void reload_text(); String get_name() ; Ref<Texture> get_icon() ; - + bool is_unsaved(); ScriptTextEditor(); }; @@ -271,6 +271,7 @@ class ScriptEditor : public VBoxContainer { void _go_to_tab(int p_idx); void _update_history_pos(int p_new_pos); void _update_script_colors(); + void _update_modified_scripts_for_external_editor(); static ScriptEditor *script_editor; @@ -302,6 +303,8 @@ public: void set_scene_root_script( Ref<Script> p_script ); + virtual void edited_scene_changed(); + ScriptEditorDebugger *get_debugger() { return debugger; } ScriptEditor(EditorNode *p_editor); @@ -338,6 +341,7 @@ public: virtual void get_breakpoints(List<String> *p_breakpoints); + virtual void edited_scene_changed(); ScriptEditorPlugin(EditorNode *p_node); ~ScriptEditorPlugin(); diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index a182d57742..848073af3e 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -235,6 +235,11 @@ void ShaderEditor::_menu_option(int p_option) { void ShaderEditor::_tab_changed(int p_which) { + ShaderTextEditor *shader_editor = tab_container->get_child(p_which)->cast_to<ShaderTextEditor>(); + + if (shader_editor) + shader_editor->get_text_edit()->grab_focus(); + ensure_select_current(); } diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index cd6dc06f75..b288439b74 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -297,6 +297,7 @@ void ProjectExportDialog::_notification(int p_what) { // _rescan(); _update_platform(); export_mode->select( EditorImportExport::get_singleton()->get_export_filter() ); + convert_text_scenes->set_pressed( EditorImportExport::get_singleton()->get_convert_text_scenes() ); filters->set_text( EditorImportExport::get_singleton()->get_export_custom_filter() ); if (EditorImportExport::get_singleton()->get_export_filter()!=EditorImportExport::EXPORT_SELECTED) tree_vb->hide(); @@ -420,6 +421,8 @@ void ProjectExportDialog::_export_mode_changed(int p_idx) { else tree_vb->show(); + EditorImportExport::get_singleton()->set_convert_text_scenes( convert_text_scenes->is_pressed() ); + _save_export_cfg(); } @@ -491,6 +494,18 @@ Error ProjectExportDialog::export_platform(const String& p_platform, const Strin Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(p_platform); if (exporter.is_null()) { ERR_PRINT("Invalid platform for export"); + + List<StringName> platforms; + EditorImportExport::get_singleton()->get_export_platforms(&platforms); + print_line("Valid export plaftorms are:"); + for (List<StringName>::Element *E=platforms.front();E;E=E->next()) + print_line(" \""+E->get()+"\""); + + if (p_quit_after) { + OS::get_singleton()->set_exit_code(255); + get_tree()->quit(); + } + return ERR_INVALID_PARAMETER; } Error err = exporter->export_project(p_path,p_debug); @@ -1125,6 +1140,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { vb = memnew( VBoxContainer ); vb->set_name("Resources"); sections->add_child(vb); + export_mode = memnew( OptionButton ); export_mode->add_item("Export selected resources (including dependencies)."); export_mode->add_item("Export all resources in the project."); @@ -1133,6 +1149,8 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { vb->add_margin_child("Export Mode:",export_mode); + + tree_vb = memnew( VBoxContainer ); vb->add_child(tree_vb); tree_vb->set_v_size_flags(SIZE_EXPAND_FILL); @@ -1153,6 +1171,10 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { vb->add_margin_child("Filters to export non-resource files (Comma Separated, ie: *.json, *.txt):",filters); filters->connect("text_changed",this,"_filters_edited"); + convert_text_scenes = memnew( CheckButton ); + convert_text_scenes->set_text("Convert text scenes to binary on export"); + vb->add_child(convert_text_scenes); + convert_text_scenes->connect("toggled",this,"_export_mode_changed"); image_vb = memnew( VBoxContainer ); image_vb->set_name("Images"); diff --git a/tools/editor/project_export.h b/tools/editor/project_export.h index 2f824e5ff7..09c8f10206 100644 --- a/tools/editor/project_export.h +++ b/tools/editor/project_export.h @@ -108,6 +108,7 @@ private: PropertyEditor *platform_options; OptionButton *export_mode; + CheckButton *convert_text_scenes; VBoxContainer *tree_vb; VBoxContainer *image_vb; diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 893df04709..4db56ea2f9 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -624,11 +624,6 @@ void ProjectManager::_open_project_confirm() { args.push_back("-editor"); - const String &selected_main = E->get(); - if (selected_main!="") { - args.push_back(selected_main); - } - String exec = OS::get_singleton()->get_executable_path(); OS::ProcessID pid=0; @@ -830,6 +825,19 @@ ProjectManager::ProjectManager() { FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); set_area_as_parent_rect(); + + Ref<Theme> theme = Ref<Theme>( memnew( Theme ) ); + set_theme(theme); + editor_register_icons(theme); + + String global_font = EditorSettings::get_singleton()->get("global/font"); + if (global_font!="") { + Ref<Font> fnt = ResourceLoader::load(global_font); + if (fnt.is_valid()) { + theme->set_default_theme_font(fnt); + } + } + Panel *panel = memnew( Panel ); add_child(panel); panel->set_area_as_parent_rect(); @@ -977,10 +985,6 @@ ProjectManager::ProjectManager() { npdialog = memnew( NewProjectDialog ); add_child(npdialog); - Ref<Theme> theme = memnew( Theme ); - editor_register_icons(theme); - set_theme(theme); - npdialog->connect("project_created", this,"_load_recent_projects"); _load_recent_projects(); diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 2fd8b37753..a2419895eb 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -722,6 +722,10 @@ void ProjectSettings::_translation_file_open() { void ProjectSettings::_autoload_file_callback(const String& p_path) { autoload_add_path->set_text(p_path); + if (autoload_add_name->get_text().strip_edges()==String()) { + + autoload_add_name->set_text( p_path.get_file().basename() ); + } //_translation_add(p_translation); } @@ -769,6 +773,9 @@ void ProjectSettings::_autoload_add() { undo_redo->add_undo_method(this,"_settings_changed"); undo_redo->commit_action(); + autoload_add_path->set_text(""); + autoload_add_name->set_text(""); + //autoload_file_open->popup_centered_ratio(); } @@ -1589,11 +1596,6 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { HBoxContainer *ahb = memnew( HBoxContainer); avb->add_child(ahb); - VBoxContainer *avb_name = memnew( VBoxContainer ); - avb_name->set_h_size_flags(SIZE_EXPAND_FILL); - autoload_add_name = memnew(LineEdit); - avb_name->add_margin_child("Node Name:",autoload_add_name); - ahb->add_child(avb_name); VBoxContainer *avb_path = memnew( VBoxContainer ); avb_path->set_h_size_flags(SIZE_EXPAND_FILL); @@ -1604,13 +1606,24 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { Button *browseaa = memnew( Button("..") ); ahb_path->add_child(browseaa); browseaa->connect("pressed",this,"_autoload_file_open"); - Button *addaa = memnew( Button("Add") ); - ahb_path->add_child(addaa); - addaa->connect("pressed",this,"_autoload_add"); avb_path->add_margin_child("Path:",ahb_path); ahb->add_child(avb_path); + VBoxContainer *avb_name = memnew( VBoxContainer ); + avb_name->set_h_size_flags(SIZE_EXPAND_FILL); + + HBoxContainer *ahb_name = memnew( HBoxContainer ); + autoload_add_name = memnew(LineEdit); + autoload_add_name->set_h_size_flags(SIZE_EXPAND_FILL); + ahb_name->add_child(autoload_add_name); + avb_name->add_margin_child("Node Name:",ahb_name); + Button *addaa = memnew( Button("Add") ); + ahb_name->add_child(addaa); + addaa->connect("pressed",this,"_autoload_add"); + + ahb->add_child(avb_name); + autoload_list = memnew( Tree ); autoload_list->set_v_size_flags(SIZE_EXPAND_FILL); avb->add_margin_child("List:",autoload_list,true); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 7687791ca2..7ab09f0487 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -1361,7 +1361,7 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::MATRIX32: { - Matrix3 m; + Matrix32 m; for(int i=0;i<6;i++) { m.elements[i/2][i%2]=value_editor[i]->get_text().to_double(); @@ -2207,9 +2207,9 @@ TreeItem *PropertyEditor::get_parent_node(String p_path,HashMap<String,TreeItem* } item->set_editable(0,false); - item->set_selectable(0,false); + item->set_selectable(0,subsection_selectable); item->set_editable(1,false); - item->set_selectable(1,false); + item->set_selectable(1,subsection_selectable); if (item->get_parent()==root) { @@ -2433,10 +2433,19 @@ void PropertyEditor::update_tree() { if (capitalize_paths) name = name.camelcase_to_underscore().capitalize(); - if (use_filter && filter!="" && name.findn(filter)==-1) - continue; - String path=p.name.left( p.name.find_last("/") ) ; + + if (use_filter && filter!="") { + + String cat = path; + + if (capitalize_paths) + cat = cat.capitalize(); + + if (cat.findn(filter)==-1 && name.findn(filter)==-1) + continue; + } + //printf("property %s\n",p.name.ascii().get_data()); TreeItem * parent = get_parent_node(path,item_path,current_category?current_category:root ); //if (parent->get_parent()==root) @@ -2837,6 +2846,13 @@ void PropertyEditor::update_tree() { item->set_icon( 0,get_icon("Vector","EditorIcons") ); } break; + case Variant::MATRIX32: + case Variant::MATRIX3: { + + item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); + item->set_editable( 1, true ); + item->set_text(1, obj->get(p.name)); + } break; case Variant::TRANSFORM: { item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); @@ -3495,7 +3511,15 @@ void PropertyEditor::register_text_enter(Node* p_line_edit) { if (search_box) search_box->connect("text_changed",this,"_filter_changed"); +} +void PropertyEditor::set_subsection_selectable(bool p_selectable) { + + if (p_selectable==subsection_selectable) + return; + + subsection_selectable=p_selectable; + update_tree(); } PropertyEditor::PropertyEditor() { @@ -3557,8 +3581,8 @@ PropertyEditor::PropertyEditor() { show_categories=false; refresh_countdown=0; use_doc_hints=false; - use_filter=false; + subsection_selectable=false; } diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index 5fb8386b1b..f004616c08 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -163,8 +163,8 @@ class PropertyEditor : public Control { bool show_categories; float refresh_countdown; bool use_doc_hints; - bool use_filter; + bool subsection_selectable; HashMap<String,String> pending; String selected_property; @@ -239,6 +239,8 @@ public: void set_use_filter(bool p_use); void register_text_enter(Node *p_line_edit); + void set_subsection_selectable(bool p_selectable); + PropertyEditor(); ~PropertyEditor(); diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 0cafe7459b..8b5bf8c1e1 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -1264,7 +1264,10 @@ void SceneTreeDock::import_subscene() { void SceneTreeDock::_import_subscene() { Node* parent = scene_tree->get_selected(); - ERR_FAIL_COND(!parent); + if (!parent) { + parent = editor_data->get_edited_scene_root(); + ERR_FAIL_COND(!parent); + } import_subscene_dialog->move(parent,edited_scene); editor_data->get_undo_redo().clear_history(); //no undo for now.. diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index ac2f76acdc..6575603073 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -565,7 +565,6 @@ void SceneTreeEditor::_notification(int p_what) { get_tree()->disconnect("node_removed",this,"_node_removed"); tree->disconnect("item_collapsed",this,"_cell_collapsed"); clear_inherit_confirm->disconnect("confirmed",this,"_subscene_option"); - _update_tree(); } } |