diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/editor_log.cpp | 2 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 93 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 6 | ||||
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | tools/editor/plugins/spatial_editor_plugin.cpp | 74 | ||||
-rw-r--r-- | tools/editor/plugins/sprite_region_editor_plugin.cpp | 55 | ||||
-rw-r--r-- | tools/editor/plugins/sprite_region_editor_plugin.h | 10 | ||||
-rw-r--r-- | tools/editor/project_manager.cpp | 2 | ||||
-rw-r--r-- | tools/editor/property_editor.cpp | 12 | ||||
-rw-r--r-- | tools/editor/quick_open.cpp | 31 | ||||
-rw-r--r-- | tools/editor/quick_open.h | 5 | ||||
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 5 |
12 files changed, 216 insertions, 85 deletions
diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp index 48f7c90066..601e53eabb 100644 --- a/tools/editor/editor_log.cpp +++ b/tools/editor/editor_log.cpp @@ -243,7 +243,7 @@ EditorLog::EditorLog() { log->set_selection_enabled(true); log->set_focus_mode(FOCUS_CLICK); pc->add_child(log); - add_message(VERSION_FULL_NAME" (c) 2008-2015 Juan Linietsky, Ariel Manzur."); + add_message(VERSION_FULL_NAME" (c) 2008-2016 Juan Linietsky, Ariel Manzur."); //log->add_text("Initialization Complete.\n"); //because it looks cool. add_style_override("panel",get_stylebox("panelf","Panel")); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 462153a183..d4596c7496 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -1450,12 +1450,6 @@ void EditorNode::_dialog_action(String p_file) { 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")); @@ -1463,8 +1457,7 @@ void EditorNode::_dialog_action(String p_file) { if (err==ERR_CANT_OPEN) { config.instance(); // new config } else if (err!=OK) { - confirm_error->set_text("Error trying to save layout!"); - confirm_error->popup_centered_minsize(); + show_warning("Error trying to save layout!"); return; } @@ -1475,25 +1468,22 @@ void EditorNode::_dialog_action(String p_file) { layout_dialog->hide(); _update_layouts_menu(); + if (p_file=="Default") { + show_warning("Default editor layout overridden."); + } + } 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 || !config->has_section(p_file)) { - confirm_error->set_text("Layout name not found!"); - confirm_error->popup_centered_minsize(); + show_warning("Layout name not found!"); return; } @@ -1509,6 +1499,10 @@ void EditorNode::_dialog_action(String p_file) { layout_dialog->hide(); _update_layouts_menu(); + if (p_file=="Default") { + show_warning("Restored Default layout to base settings."); + } + } break; default: { //save scene? @@ -2081,21 +2075,21 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case FILE_QUICK_OPEN_SCENE: { - quick_open->popup("PackedScene"); + quick_open->popup("PackedScene", true); quick_open->set_title("Quick Open Scene.."); } break; case FILE_QUICK_OPEN_SCRIPT: { - quick_open->popup("Script"); + quick_open->popup("Script", true); quick_open->set_title("Quick Open Script.."); } break; case FILE_QUICK_OPEN_FILE: { - quick_open->popup("Resource",false,true); + quick_open->popup("Resource", false, true); quick_open->set_title("Quick Search File.."); } break; @@ -3174,7 +3168,7 @@ Error EditorNode::save_translatable_strings(const String& p_to_file) { OS::Time time = OS::get_singleton()->get_time(); f->store_line("# Translation Strings Dump."); f->store_line("# Created By."); - f->store_line("# \t" VERSION_FULL_NAME " (c) 2008-2015 Juan Linietsky, Ariel Manzur."); + f->store_line("# \t" VERSION_FULL_NAME " (c) 2008-2016 Juan Linietsky, Ariel Manzur."); f->store_line("# From Scene: "); f->store_line("# \t"+get_edited_scene()->get_filename()); f->store_line(""); @@ -3931,19 +3925,26 @@ void EditorNode::hide_animation_player_editors() { emit_signal("hide_animation_player_editors"); } -void EditorNode::_quick_opened(const String& p_resource) { +void EditorNode::_quick_opened() { if (current_option==FILE_QUICK_OPEN_FILE) { - scenes_dock->open(p_resource); + String res_path = quick_open->get_selected(); + + scenes_dock->open(res_path); return; } - if (quick_open->get_base_type()=="PackedScene") { - open_request(p_resource); - } else { - load_resource(p_resource); - } + Vector<String> files = quick_open->get_selected_files(); + + for (int i = 0; i < files.size(); i++) { + String res_path = files[i]; + if (quick_open->get_base_type()=="PackedScene") { + open_request(res_path); + } else { + load_resource(res_path); + } + } } void EditorNode::_quick_run(const String& p_resource) { @@ -4511,7 +4512,11 @@ void EditorNode::_load_docks() { config.instance(); Error err = config->load(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg")); if (err!=OK) { - return; //no config + //no config + if (overridden_default_layout>=0) { + _layout_menu_option(overridden_default_layout); + } + return; } _load_docks_from_config(config, "docks"); @@ -4613,6 +4618,8 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String& void EditorNode::_update_layouts_menu() { editor_layouts->clear(); + overridden_default_layout=-1; + editor_layouts->set_size(Vector2()); editor_layouts->add_item("Save Layout", SETTINGS_LAYOUT_SAVE); editor_layouts->add_item("Delete Layout", SETTINGS_LAYOUT_DELETE); @@ -4633,8 +4640,12 @@ void EditorNode::_update_layouts_menu() { String layout=E->get(); - if (layout!="Default") - editor_layouts->add_item(layout); + if (layout=="Default") { + editor_layouts->remove_item(editor_layouts->get_item_index(SETTINGS_LAYOUT_DEFAULT)); + overridden_default_layout=editor_layouts->get_item_count(); + } + + editor_layouts->add_item(layout); } } @@ -4659,7 +4670,7 @@ void EditorNode::_layout_menu_option(int p_id) { } break; case SETTINGS_LAYOUT_DEFAULT: { - _load_docks_from_config(default_theme, "docks"); + _load_docks_from_config(default_layout, "docks"); _save_docks(); } break; default: { @@ -4673,7 +4684,6 @@ void EditorNode::_layout_menu_option(int p_id) { _load_docks_from_config(config, editor_layouts->get_item_text(p_id)); _save_docks(); - } } @@ -4723,11 +4733,13 @@ void EditorNode::_scene_tab_changed(int p_tab) { editor_data.get_undo_redo().add_do_method(this,"set_current_version",unsaved?saved_version:0); editor_data.get_undo_redo().add_do_method(this,"set_current_scene",p_tab); editor_data.get_undo_redo().add_do_method(scene_tabs,"set_current_tab",p_tab); + editor_data.get_undo_redo().add_do_method(scene_tabs,"ensure_tab_visible",p_tab); editor_data.get_undo_redo().add_do_method(this,"set_current_version",next_scene_version==0?editor_data.get_undo_redo().get_version()+1:next_scene_version); editor_data.get_undo_redo().add_undo_method(this,"set_current_version",next_scene_version); editor_data.get_undo_redo().add_undo_method(this,"set_current_scene",editor_data.get_edited_scene()); editor_data.get_undo_redo().add_undo_method(scene_tabs,"set_current_tab",editor_data.get_edited_scene()); + editor_data.get_undo_redo().add_undo_method(scene_tabs,"ensure_tab_visible",p_tab,editor_data.get_edited_scene()); editor_data.get_undo_redo().add_undo_method(this,"set_current_version",saved_version); editor_data.get_undo_redo().commit_action(); @@ -5456,8 +5468,6 @@ EditorNode::EditorNode() { 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("name_confirmed", this,"_dialog_action"); sources_button = memnew( ToolButton ); @@ -5648,15 +5658,16 @@ EditorNode::EditorNode() { 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"); + overridden_default_layout=-1; + default_layout.instance(); + default_layout->set_value(docks_section, "dock_3", "Scene"); + default_layout->set_value(docks_section, "dock_4", "FileSystem"); + default_layout->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); + default_layout->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); + default_layout->set_value(docks_section, "dock_split_"+itos(i+1), 0); _update_layouts_menu(); @@ -5799,7 +5810,7 @@ EditorNode::EditorNode() { about->get_ok()->set_text("Thanks!"); about->set_hide_on_ok(true); Label *about_text = memnew( Label ); - about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2015 Juan Linietsky, Ariel Manzur.\n"); + about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2016 Juan Linietsky, Ariel Manzur.\n"); about_text->set_pos(Point2(gui_base->get_icon("Logo","EditorIcons")->get_size().width+30,20)); gui_base->add_child(about); about->add_child(about_text); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 2228e0948b..d8d76d47cc 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -288,10 +288,10 @@ class EditorNode : public Node { AcceptDialog *about; AcceptDialog *warning; - Ref<ConfigFile> default_theme; + int overridden_default_layout; + Ref<ConfigFile> default_layout; PopupMenu *editor_layouts; EditorNameDialog *layout_dialog; - AcceptDialog *confirm_error; //OptimizedPresetsDialog *optimized_presets; EditorSettingsDialog *settings_config_dialog; @@ -440,7 +440,7 @@ class EditorNode : public Node { void _update_keying(); void _hide_top_editors(); - void _quick_opened(const String& p_resource); + void _quick_opened(); void _quick_run(const String& p_resource); void _run(bool p_current=false, const String &p_custom=""); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 6c36c71e93..fc0d68b2f8 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -327,7 +327,11 @@ void ScriptTextEditor::_load_theme_settings() { for(List<StringName>::Element *E=types.front();E;E=E->next()) { - get_text_edit()->add_keyword_color(E->get(),type_color); + String n = E->get(); + if (n.begins_with("_")) + n = n.substr(1, n.length()); + + get_text_edit()->add_keyword_color(n,type_color); } //colorize comments diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 0fac1346fc..29d2a7774c 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -2629,6 +2629,13 @@ Dictionary SpatialEditor::get_state() const { Dictionary d; + d["snap_enabled"]=snap_enabled; + d["translate_snap"]=get_translate_snap(); + d["rotate_snap"]=get_rotate_snap(); + d["scale_snap"]=get_scale_snap(); + + int local_coords_index=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS); + d["local_coords"]=transform_menu->get_popup()->is_item_checked( local_coords_index ); int vc=0; if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT) )) @@ -2670,37 +2677,52 @@ void SpatialEditor::set_state(const Dictionary& p_state) { Dictionary d = p_state; - ERR_FAIL_COND(!d.has("viewport_mode")); - ERR_FAIL_COND(!d.has("viewports")); - ERR_FAIL_COND(!d.has("default_light")); - ERR_FAIL_COND(!d.has("show_grid")); - ERR_FAIL_COND(!d.has("show_origin")); - ERR_FAIL_COND(!d.has("fov")); - ERR_FAIL_COND(!d.has("znear")); - ERR_FAIL_COND(!d.has("zfar")); + if (d.has("snap_enabled")) { + snap_enabled=d["snap_enabled"]; + int snap_enabled_idx=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_USE_SNAP); + transform_menu->get_popup()->set_item_checked( snap_enabled_idx, snap_enabled ); + } - int vc = d["viewport_mode"]; + if (d.has("translate_snap")) + snap_translate->set_text(d["translate_snap"]); - if (vc==1) - _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT); - else if (vc==2) - _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS); - else if (vc==3) - _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS); - else if (vc==4) - _menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS); - else if (vc==5) - _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT); - else if (vc==6) - _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT); - - Array vp = d["viewports"]; - ERR_FAIL_COND(vp.size()>4); + if (d.has("rotate_snap")) + snap_rotate->set_text(d["rotate_snap"]); - for(int i=0;i<4;i++) { - viewports[i]->set_state(vp[i]); + if (d.has("scale_snap")) + snap_scale->set_text(d["scale_snap"]); + + if (d.has("local_coords")) { + int local_coords_idx=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS); + transform_menu->get_popup()->set_item_checked( local_coords_idx, d["local_coords"] ); + update_transform_gizmo(); + } + + if (d.has("viewport_mode")) { + int vc = d["viewport_mode"]; + + if (vc==1) + _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT); + else if (vc==2) + _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS); + else if (vc==3) + _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS); + else if (vc==4) + _menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS); + else if (vc==5) + _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT); + else if (vc==6) + _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT); } + if (d.has("viewports")) { + Array vp = d["viewports"]; + ERR_FAIL_COND(vp.size()>4); + + for(int i=0;i<4;i++) { + viewports[i]->set_state(vp[i]); + } + } if (d.has("zfar")) settings_zfar->set_val(float(d["zfar"])); diff --git a/tools/editor/plugins/sprite_region_editor_plugin.cpp b/tools/editor/plugins/sprite_region_editor_plugin.cpp index 2653973226..725de19dd7 100644 --- a/tools/editor/plugins/sprite_region_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_region_editor_plugin.cpp @@ -411,6 +411,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) snap_step=Vector2(10,10); use_snap=false; snap_show_grid=false; + drag=false; add_child( memnew( VSeparator )); edit_node = memnew( ToolButton ); @@ -449,7 +450,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) hb_tools->add_child( memnew( VSeparator )); hb_tools->add_child( memnew( Label("Grid Offset:") ) ); - SpinBox *sb_off_x = memnew( SpinBox ); + sb_off_x = memnew( SpinBox ); sb_off_x->set_min(-256); sb_off_x->set_max(256); sb_off_x->set_step(1); @@ -458,7 +459,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) sb_off_x->connect("value_changed", this, "_set_snap_off_x"); hb_tools->add_child(sb_off_x); - SpinBox *sb_off_y = memnew( SpinBox ); + sb_off_y = memnew( SpinBox ); sb_off_y->set_min(-256); sb_off_y->set_max(256); sb_off_y->set_step(1); @@ -470,7 +471,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) hb_tools->add_child( memnew( VSeparator )); hb_tools->add_child( memnew( Label("Grid Step:") ) ); - SpinBox *sb_step_x = memnew( SpinBox ); + sb_step_x = memnew( SpinBox ); sb_step_x->set_min(-256); sb_step_x->set_max(256); sb_step_x->set_step(1); @@ -479,7 +480,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) sb_step_x->connect("value_changed", this, "_set_snap_step_x"); hb_tools->add_child(sb_step_x); - SpinBox *sb_step_y = memnew( SpinBox ); + sb_step_y = memnew( SpinBox ); sb_step_y->set_min(-256); sb_step_y->set_max(256); sb_step_y->set_step(1); @@ -488,8 +489,6 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) sb_step_y->connect("value_changed", this, "_set_snap_step_y"); hb_tools->add_child(sb_step_y); -// MARIANOGNU::TODO: Add more tools? - HBoxContainer *main_hb = memnew( HBoxContainer ); main_vb->add_child(main_hb); edit_draw = memnew( Control ); @@ -554,6 +553,50 @@ void SpriteRegionEditorPlugin::make_visible(bool p_visible) } } + +Dictionary SpriteRegionEditorPlugin::get_state() const { + + Dictionary state; + state["zoom"]=region_editor->zoom->get_val(); + state["snap_offset"]=region_editor->snap_offset; + state["snap_step"]=region_editor->snap_step; + state["use_snap"]=region_editor->use_snap; + state["snap_show_grid"]=region_editor->snap_show_grid; + return state; +} + +void SpriteRegionEditorPlugin::set_state(const Dictionary& p_state){ + + Dictionary state=p_state; + if (state.has("zoom")) { + region_editor->zoom->set_val(p_state["zoom"]); + } + + if (state.has("snap_step")) { + Vector2 s = state["snap_step"]; + region_editor->sb_step_x->set_val(s.x); + region_editor->sb_step_y->set_val(s.y); + region_editor->snap_step = s; + } + + if (state.has("snap_offset")) { + Vector2 ofs = state["snap_offset"]; + region_editor->sb_off_x->set_val(ofs.x); + region_editor->sb_off_y->set_val(ofs.y); + region_editor->snap_offset = ofs; + } + + if (state.has("use_snap")) { + region_editor->use_snap=state["use_snap"]; + region_editor->b_snap_enable->set_pressed(state["use_snap"]); + } + + if (state.has("snap_show_grid")) { + region_editor->snap_show_grid=state["snap_show_grid"]; + region_editor->b_snap_grid->set_pressed(state["snap_show_grid"]); + } +} + SpriteRegionEditorPlugin::SpriteRegionEditorPlugin(EditorNode *p_node) { editor = p_node; diff --git a/tools/editor/plugins/sprite_region_editor_plugin.h b/tools/editor/plugins/sprite_region_editor_plugin.h index fafa2e119b..47cb210863 100644 --- a/tools/editor/plugins/sprite_region_editor_plugin.h +++ b/tools/editor/plugins/sprite_region_editor_plugin.h @@ -41,6 +41,8 @@ class SpriteRegionEditor : public HBoxContainer { OBJ_TYPE(SpriteRegionEditor, HBoxContainer ); + friend class SpriteRegionEditorPlugin; + ToolButton *edit_node; // Button *use_region; ToolButton *b_snap_enable; @@ -48,6 +50,10 @@ class SpriteRegionEditor : public HBoxContainer { TextureFrame *icon_zoom; HSlider *zoom; SpinBox *zoom_value; + SpinBox *sb_step_y; + SpinBox *sb_step_x; + SpinBox *sb_off_y; + SpinBox *sb_off_x; Control *edit_draw; VScrollBar *vscroll; @@ -113,11 +119,13 @@ class SpriteRegionEditorPlugin : public EditorPlugin EditorNode *editor; public: - virtual String get_name() const { return "Sprite"; } + virtual String get_name() const { return "SpriteRegion"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_node); virtual bool handles(Object *p_node) const; virtual void make_visible(bool p_visible); + void set_state(const Dictionary &p_state); + Dictionary get_state() const; SpriteRegionEditorPlugin(EditorNode *p_node); }; diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 5fd9118a32..589d9d3d99 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -964,7 +964,7 @@ ProjectManager::ProjectManager() { String cp; cp.push_back(0xA9); cp.push_back(0); - l->set_text(cp+" 2008-2015 Juan Linietsky, Ariel Manzur."); + l->set_text(cp+" 2008-2016 Juan Linietsky, Ariel Manzur."); l->set_align(Label::ALIGN_CENTER); vb->add_child(l); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index d0a37f0c7d..9743dc7202 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -727,7 +727,17 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty RES cb=EditorSettings::get_singleton()->get_resource_clipboard(); - bool paste_valid=cb.is_valid() && (hint_text=="" || ObjectTypeDB::is_type(cb->get_type(),hint_text)); + bool paste_valid=false; + if (cb.is_valid()) { + if (hint_text=="") + paste_valid=true; + else + for (int i = 0; i < hint_text.get_slice_count(",");i++) + if (ObjectTypeDB::is_type(cb->get_type(),hint_text.get_slice(",",i))) { + paste_valid=true; + break; + } + } if (!RES(v).is_null() || paste_valid) { menu->add_separator(); diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp index bfbcb739ac..22f4a40c83 100644 --- a/tools/editor/quick_open.cpp +++ b/tools/editor/quick_open.cpp @@ -30,7 +30,7 @@ #include "os/keyboard.h" -void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_add_dirs) { +void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) { add_directories=p_add_dirs; popup_centered_ratio(0.6); @@ -38,13 +38,38 @@ void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_a search_box->select_all(); else search_box->clear(); + if (p_enable_multi) + search_options->set_select_mode(Tree::SELECT_MULTI); + else + search_options->set_select_mode(Tree::SELECT_SINGLE); search_box->grab_focus(); base_type=p_base; _update_search(); +} + +String EditorQuickOpen::get_selected() const { + TreeItem *ti = search_options->get_selected(); + if (!ti) + return String(); + return "res://" + ti->get_text(0); } +Vector<String> EditorQuickOpen::get_selected_files() const { + + Vector<String> files; + + TreeItem* item = search_options->get_next_selected(search_options->get_root()); + while (item) { + + files.push_back("res://"+item->get_text(0)); + + item = search_options->get_next_selected(item); + } + + return files; +} void EditorQuickOpen::_text_changed(const String& p_newtext) { @@ -132,7 +157,7 @@ void EditorQuickOpen::_confirmed() { TreeItem *ti = search_options->get_selected(); if (!ti) return; - emit_signal("quick_open","res://"+ti->get_text(0)); + emit_signal("quick_open"); hide(); } @@ -156,7 +181,7 @@ void EditorQuickOpen::_bind_methods() { ObjectTypeDB::bind_method(_MD("_confirmed"),&EditorQuickOpen::_confirmed); ObjectTypeDB::bind_method(_MD("_sbox_input"),&EditorQuickOpen::_sbox_input); - ADD_SIGNAL(MethodInfo("quick_open",PropertyInfo(Variant::STRING,"respath"))); + ADD_SIGNAL(MethodInfo("quick_open")); } diff --git a/tools/editor/quick_open.h b/tools/editor/quick_open.h index 7f2091e5d1..520f7e569d 100644 --- a/tools/editor/quick_open.h +++ b/tools/editor/quick_open.h @@ -61,7 +61,10 @@ public: StringName get_base_type() const; - void popup(const StringName& p_base,bool p_dontclear=false,bool p_add_dirs=false); + String get_selected() const; + Vector<String> get_selected_files() const; + + void popup(const StringName& p_base,bool p_enable_multi=false,bool p_add_dirs=false,bool p_dontclear=false); EditorQuickOpen(); }; diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 75f1597b20..89036d2581 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -1268,6 +1268,11 @@ void SceneTreeDock::_create() { editor->set_edited_scene(newnode); } + //small hack to make collisionshapes and other kind of nodes to work + for(int i=0;i<newnode->get_child_count();i++) { + Node *c=newnode->get_child(i); + c->call("set_transform", c->call("get_transform") ); + } editor_data->get_undo_redo().clear_history(); newnode->set_name(newname); |