diff options
Diffstat (limited to 'tools/editor')
99 files changed, 3303 insertions, 2291 deletions
diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index dd3c3fee32..9eb6b4013f 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -85,7 +85,6 @@ private: int points = 48; if (mode==MODE_MULTIPLE) { - int max_draw = 16; Color mcolor=color; mcolor.a*=0.3; @@ -694,11 +693,103 @@ void AnimationKeyEditor::_menu_add_track(int p_type) { } } +void AnimationKeyEditor::_anim_duplicate_keys(bool transpose) { + //duplicait! + if (selection.size() && animation.is_valid() && selected_track>=0 && selected_track<animation->get_track_count()) { + + int top_track=0x7FFFFFFF; + float top_time = 1e10; + for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) { + + const SelectedKey &sk = E->key(); + + float t = animation->track_get_key_time(sk.track,sk.key); + if (t<top_time) + top_time=t; + if (sk.track<top_track) + top_track=sk.track; + + } + ERR_FAIL_COND( top_track == 0x7FFFFFFF || top_time==1e10 ); + + // + + int start_track = transpose ? selected_track : top_track; + + undo_redo->create_action(TTR("Anim Duplicate Keys")); + + List<Pair<int,float> > new_selection_values; + + for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) { + + const SelectedKey &sk = E->key(); + + float t = animation->track_get_key_time(sk.track,sk.key); + + float dst_time = t+(timeline_pos - top_time); + int dst_track = sk.track + (start_track - top_track); + + if (dst_track < 0 || dst_track>= animation->get_track_count()) + continue; + + if (animation->track_get_type(dst_track) != animation->track_get_type(sk.track)) + continue; + + int existing_idx = animation->track_find_key(dst_track,dst_time,true); + + undo_redo->add_do_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key)); + undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",dst_track,dst_time); + + Pair<int,float> p; + p.first=dst_track; + p.second=dst_time; + new_selection_values.push_back( p ); + + if (existing_idx!=-1) { + + undo_redo->add_undo_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(dst_track,existing_idx),animation->track_get_key_transition(dst_track,existing_idx)); + + } + + } + + undo_redo->commit_action(); + + //reselect duplicated + + Map<SelectedKey,KeyInfo> new_selection; + for (List<Pair<int,float> >::Element *E=new_selection_values.front();E;E=E->next()) { + + int track=E->get().first; + float time = E->get().second; + + int existing_idx = animation->track_find_key(track,time,true); + + if (existing_idx==-1) + continue; + SelectedKey sk2; + sk2.track=track; + sk2.key=existing_idx; + + KeyInfo ki; + ki.pos=time; + + new_selection[sk2]=ki; + + } + + + selection=new_selection; + track_editor->update(); + _edit_if_single_selection(); + + } +} + void AnimationKeyEditor::_menu_track(int p_type) { ERR_FAIL_COND(!animation.is_valid()); - last_menu_track_opt=p_type; switch(p_type) { @@ -766,108 +857,7 @@ void AnimationKeyEditor::_menu_track(int p_type) { case TRACK_MENU_DUPLICATE: case TRACK_MENU_DUPLICATE_TRANSPOSE: { - - //duplicait! - if (selection.size() && animation.is_valid() && selected_track>=0 && selected_track<animation->get_track_count()) { - - - int top_track=0x7FFFFFFF; - float top_time = 1e10; - for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) { - - const SelectedKey &sk = E->key(); - - float t = animation->track_get_key_time(sk.track,sk.key); - if (t<top_time) - top_time=t; - if (sk.track<top_track) - top_track=sk.track; - - - } - ERR_FAIL_COND( top_track == 0x7FFFFFFF || top_time==1e10 ); - - // - - int start_track = p_type==TRACK_MENU_DUPLICATE_TRANSPOSE ? selected_track : top_track; - - - undo_redo->create_action(TTR("Anim Duplicate Keys")); - - List<Pair<int,float> > new_selection_values; - - for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) { - - const SelectedKey &sk = E->key(); - - float t = animation->track_get_key_time(sk.track,sk.key); - - float dst_time = t+(timeline_pos - top_time); - int dst_track = sk.track + (start_track - top_track); - - if (dst_track < 0 || dst_track>= animation->get_track_count()) - continue; - - if (animation->track_get_type(dst_track) != animation->track_get_type(sk.track)) - continue; - - int existing_idx = animation->track_find_key(dst_track,dst_time,true); - - undo_redo->add_do_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key)); - undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",dst_track,dst_time); - - Pair<int,float> p; - p.first=dst_track; - p.second=dst_time; - new_selection_values.push_back( p ); - - if (existing_idx!=-1) { - - undo_redo->add_undo_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(dst_track,existing_idx),animation->track_get_key_transition(dst_track,existing_idx)); - - } - - - - } - - undo_redo->commit_action(); - - //reselect duplicated - - Map<SelectedKey,KeyInfo> new_selection; - for (List<Pair<int,float> >::Element *E=new_selection_values.front();E;E=E->next()) { - - - int track=E->get().first; - float time = E->get().second; - - int existing_idx = animation->track_find_key(track,time,true); - - if (existing_idx==-1) - continue; - SelectedKey sk2; - sk2.track=track; - sk2.key=existing_idx; - - KeyInfo ki; - ki.pos=time; - - - new_selection[sk2]=ki; - - - } - - - selection=new_selection; - track_editor->update(); - _edit_if_single_selection(); - - - } - - + _anim_duplicate_keys(p_type==TRACK_MENU_DUPLICATE_TRANSPOSE); } break; case TRACK_MENU_SET_ALL_TRANS_LINEAR: case TRACK_MENU_SET_ALL_TRANS_CONSTANT: @@ -1356,7 +1346,6 @@ void AnimationKeyEditor::_track_editor_draw() { } } - Color sep_color=color; color.a*=0.5; for(int i=0;i<fit;i++) { @@ -1620,9 +1609,7 @@ void AnimationKeyEditor::_track_menu_selected(int p_idx) { undo_redo->add_do_method(animation.ptr(),"track_set_interpolation_type",interp_editing,p_idx); undo_redo->add_undo_method(animation.ptr(),"track_set_interpolation_type",interp_editing,animation->track_get_interpolation_type(interp_editing)); undo_redo->commit_action(); - } - - if (cont_editing!=-1) { + } else if (cont_editing!=-1) { ERR_FAIL_INDEX(cont_editing,animation->get_track_count()); @@ -1630,6 +1617,16 @@ void AnimationKeyEditor::_track_menu_selected(int p_idx) { undo_redo->add_do_method(animation.ptr(),"value_track_set_update_mode",cont_editing,p_idx); undo_redo->add_undo_method(animation.ptr(),"value_track_set_update_mode",cont_editing,animation->value_track_get_update_mode(cont_editing)); undo_redo->commit_action(); + } else { + switch (p_idx) { + + case RIGHT_MENU_DUPLICATE: + _anim_duplicate_keys(); break; + case RIGHT_MENU_DUPLICATE_TRANSPOSE: + _anim_duplicate_keys(true); break; + case RIGHT_MENU_REMOVE: + _anim_delete_keys(); break; + } } } @@ -1791,6 +1788,25 @@ bool AnimationKeyEditor::_edit_if_single_selection() { } +void AnimationKeyEditor::_anim_delete_keys() { + if (selection.size()) { + undo_redo->create_action(TTR("Anim Delete Keys")); + + for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) { + + undo_redo->add_do_method(animation.ptr(),"track_remove_key",E->key().track,E->key().key); + undo_redo->add_undo_method(animation.ptr(),"track_insert_key",E->key().track,E->get().pos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key)); + + } + undo_redo->add_do_method(this,"_clear_selection_for_anim",animation); + undo_redo->add_undo_method(this,"_clear_selection_for_anim",animation); + undo_redo->commit_action(); + //selection.clear(); + accept_event(); + _edit_if_single_selection(); + } +} + void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { Control *te=track_editor; @@ -1806,8 +1822,6 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { Ref<Font> font = te->get_font("font","Tree"); int sep = get_constant("vseparation","Tree"); int hsep = get_constant("hseparation","Tree"); - Color color = get_color("font_color","Tree"); - Color sepcolor = get_color("guide_color","Tree"); Ref<Texture> remove_icon = get_icon("Remove","EditorIcons"); Ref<Texture> move_up_icon = get_icon("MoveUp","EditorIcons"); Ref<Texture> move_down_icon = get_icon("MoveDown","EditorIcons"); @@ -1863,22 +1877,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { } else if (p_input.key.scancode==KEY_DELETE && p_input.key.pressed && click.click==ClickOver::CLICK_NONE) { - if (selection.size()) { - undo_redo->create_action(TTR("Anim Delete Keys")); - - for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) { - - undo_redo->add_do_method(animation.ptr(),"track_remove_key",E->key().track,E->key().key); - undo_redo->add_undo_method(animation.ptr(),"track_insert_key",E->key().track,E->get().pos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key)); - - } - undo_redo->add_do_method(this,"_clear_selection_for_anim",animation); - undo_redo->add_undo_method(this,"_clear_selection_for_anim",animation); - undo_redo->commit_action(); - //selection.clear(); - accept_event(); - _edit_if_single_selection(); - } + _anim_delete_keys(); } else if (animation.is_valid() && animation->get_track_count()>0) { if (p_input.is_pressed() && (p_input.is_action("ui_up") || p_input.is_action("ui_page_up"))) { @@ -1938,6 +1937,116 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { v_scroll->set_val( v_scroll->get_val() + v_scroll->get_page() / 8 ); } + if (mb.button_index==BUTTON_RIGHT && mb.pressed) { + + Point2 mpos = Point2(mb.x,mb.y)-ofs; + + if (selection.size() == 0) { + // Auto-select on right-click if nothing is selected + // Note: This code is pretty much duplicated from the left click code, + // both codes could be moved into a function to avoid the duplicated code. + Point2 mpos = Point2(mb.x,mb.y)-ofs; + + if (mpos.y < h ) { + return; + } + + mpos.y -= h; + + int idx = mpos.y / h; + idx+=v_scroll->get_val(); + if (idx <0 || idx>=animation->get_track_count()) + break; + + if (mpos.x < name_limit) { + } else if (mpos.x < settings_limit) { + float pos = mpos.x - name_limit; + pos/=_get_zoom_scale(); + pos+=h_scroll->get_val(); + float w_time = (type_icon[0]->get_width() / _get_zoom_scale())/2.0; + + int kidx = animation->track_find_key(idx,pos); + int kidx_n = kidx+1; + int key=-1; + + if (kidx>=0 && kidx<animation->track_get_key_count(idx)) { + + float kpos = animation->track_get_key_time(idx,kidx); + if (ABS(pos-kpos)<=w_time) { + + key=kidx; + } + } + + if (key==-1 && kidx_n>=0 && kidx_n<animation->track_get_key_count(idx)) { + + float kpos = animation->track_get_key_time(idx,kidx_n); + if (ABS(pos-kpos)<=w_time) { + + key=kidx_n; + } + } + + if (key==-1) { + + click.click=ClickOver::CLICK_SELECT_KEYS; + click.at=Point2(mb.x,mb.y); + click.to=click.at; + click.shift=mb.mod.shift; + selected_track=idx; + track_editor->update(); + //drag select region + return; + + } + + + + SelectedKey sk; + sk.track=idx; + sk.key=key; + KeyInfo ki; + ki.pos= animation->track_get_key_time(idx,key); + click.shift=mb.mod.shift; + click.selk=sk; + + + if (!mb.mod.shift && !selection.has(sk)) + _clear_selection(); + + selection.insert(sk,ki); + + click.click=ClickOver::CLICK_MOVE_KEYS; + click.at=Point2(mb.x,mb.y); + click.to=click.at; + update(); + selected_track=idx; + track_editor->update(); + + if (_edit_if_single_selection() && mb.mod.command) { + edit_button->set_pressed(true); + key_editor_tab->show(); + } + } + } + + if (selection.size()) { + // User has right clicked and we have a selection, show a popup menu with options + track_menu->clear(); + track_menu->set_size(Point2(1,1)); + track_menu->add_item(TTR("Duplicate Selection"), RIGHT_MENU_DUPLICATE); + track_menu->add_item(TTR("Duplicate Transposed"), RIGHT_MENU_DUPLICATE_TRANSPOSE); + track_menu->add_item(TTR("Remove Selection"), RIGHT_MENU_REMOVE); + + track_menu->set_pos(te->get_global_pos()+mpos); + + interp_editing=-1; + cont_editing=-1; + + track_menu->popup(); + } + } + if (mb.button_index==BUTTON_LEFT && !(mb.button_mask&~BUTTON_MASK_LEFT)) { @@ -2922,7 +3031,6 @@ void AnimationKeyEditor::_notification(int p_what) { edit_button->connect("pressed",this,"_toggle_edit_curves"); loop->set_icon(get_icon("Loop","EditorIcons")); - loop_interpolation->set_icon(get_icon("LoopInterpolation","EditorIcons")); curve_edit->connect("transition_changed",this,"_curve_transition_changed"); //edit_button->add_color_override("font_color",get_color("font_color","Tree")); @@ -3008,12 +3116,10 @@ void AnimationKeyEditor::_update_menu() { updating=true; - bool empty= !animation.is_valid(); if (animation.is_valid()) { length->set_val(animation->get_length()); loop->set_pressed(animation->has_loop()); - loop_interpolation->set_pressed(animation->has_loop_interpolation()); step->set_val(animation->get_step()); } @@ -3469,21 +3575,6 @@ void AnimationKeyEditor::_animation_loop_changed() { } -void AnimationKeyEditor::_animation_loop_interpolation_changed() { - - if (updating) - return; - - if (!animation.is_null()) { - - undo_redo->create_action(TTR("Change Anim Loop Interpolation")); - undo_redo->add_do_method(animation.ptr(),"set_loop_interpolation",loop_interpolation->is_pressed()); - undo_redo->add_undo_method(animation.ptr(),"set_loop_interpolation",!loop_interpolation->is_pressed()); - undo_redo->commit_action(); - } - -} - void AnimationKeyEditor::_create_value_item(int p_type) { @@ -3769,7 +3860,6 @@ void AnimationKeyEditor::_bind_methods() { ObjectTypeDB::bind_method(_MD("_animation_loop_changed"),&AnimationKeyEditor::_animation_loop_changed); - ObjectTypeDB::bind_method(_MD("_animation_loop_interpolation_changed"),&AnimationKeyEditor::_animation_loop_interpolation_changed); ObjectTypeDB::bind_method(_MD("_animation_len_changed"),&AnimationKeyEditor::_animation_len_changed); ObjectTypeDB::bind_method(_MD("_create_value_item"),&AnimationKeyEditor::_create_value_item); ObjectTypeDB::bind_method(_MD("_pane_drag"),&AnimationKeyEditor::_pane_drag); @@ -3880,12 +3970,6 @@ AnimationKeyEditor::AnimationKeyEditor() { hb->add_child(loop); loop->set_tooltip(TTR("Enable/Disable looping in animation.")); - loop_interpolation = memnew( ToolButton ); - loop_interpolation->set_toggle_mode(true); - loop_interpolation->connect("pressed",this,"_animation_loop_interpolation_changed"); - hb->add_child(loop_interpolation); - loop_interpolation->set_tooltip(TTR("Enable/Disable interpolation when looping animation.")); - hb->add_child( memnew( VSeparator ) ); menu_add_track = memnew( MenuButton ); diff --git a/tools/editor/animation_editor.h b/tools/editor/animation_editor.h index c8de1d87c1..131100a205 100644 --- a/tools/editor/animation_editor.h +++ b/tools/editor/animation_editor.h @@ -99,6 +99,12 @@ class AnimationKeyEditor : public VBoxContainer { CURVE_SET_CONSTANT }; + enum { + RIGHT_MENU_DUPLICATE, + RIGHT_MENU_DUPLICATE_TRANSPOSE, + RIGHT_MENU_REMOVE + }; + struct MouseOver { enum Over { @@ -173,7 +179,6 @@ class AnimationKeyEditor : public VBoxContainer { //MenuButton *menu; SpinBox *length; Button *loop; - Button *loop_interpolation; bool keying; ToolButton *edit_button; ToolButton *move_up_button; @@ -239,7 +244,6 @@ class AnimationKeyEditor : public VBoxContainer { void _animation_len_changed(float p_len); void _animation_loop_changed(); - void _animation_loop_interpolation_changed(); void _step_changed(float p_len); struct InsertData { @@ -315,6 +319,9 @@ class AnimationKeyEditor : public VBoxContainer { void _add_call_track(const NodePath& p_base); + void _anim_duplicate_keys(bool transpose = false); + void _anim_delete_keys(); + void _root_removed(); protected: diff --git a/tools/editor/asset_library_editor_plugin.cpp b/tools/editor/asset_library_editor_plugin.cpp index a2448921d7..4f685badfb 100644 --- a/tools/editor/asset_library_editor_plugin.cpp +++ b/tools/editor/asset_library_editor_plugin.cpp @@ -444,6 +444,13 @@ void EditorAssetLibraryItemDownload::_close() { void EditorAssetLibraryItemDownload::_install() { String file = download->get_download_file(); + + if (external_install) { + emit_signal("install_asset",file,title->get_text()); + return; + } + + asset_installer->open(file,1); } @@ -465,6 +472,8 @@ void EditorAssetLibraryItemDownload::_bind_methods() { ObjectTypeDB::bind_method("_close",&EditorAssetLibraryItemDownload::_close); ObjectTypeDB::bind_method("_make_request",&EditorAssetLibraryItemDownload::_make_request); + ADD_SIGNAL(MethodInfo("install_asset",PropertyInfo(Variant::STRING,"zip_path"),PropertyInfo(Variant::STRING,"name"))); + } EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { @@ -530,6 +539,8 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { prev_status=-1; + external_install=false; + } @@ -600,7 +611,8 @@ void EditorAssetLibrary::_install_asset() { EditorAssetLibraryItemDownload *d = downloads_hb->get_child(i)->cast_to<EditorAssetLibraryItemDownload>(); if (d && d->get_asset_id() == description->get_asset_id()) { - EditorNode::get_singleton()->show_warning("Download for this asset is already in progress!"); + if (EditorNode::get_singleton() != NULL) + EditorNode::get_singleton()->show_warning("Download for this asset is already in progress!"); return; } } @@ -610,6 +622,11 @@ void EditorAssetLibrary::_install_asset() { downloads_hb->add_child(download); download->configure(description->get_title(),description->get_asset_id(),description->get_preview_icon(),description->get_download_url(),description->get_sha256()); + if (templates_only) { + download->set_external_install(true); + download->connect("install_asset",this,"_install_external_asset"); + } + } const char* EditorAssetLibrary::sort_key[SORT_MAX]={ @@ -1258,6 +1275,11 @@ void EditorAssetLibrary::_manage_plugins() { +void EditorAssetLibrary::_install_external_asset(String p_zip_path,String p_title) { + + emit_signal("install_asset",p_zip_path,p_title); +} + void EditorAssetLibrary::_bind_methods() { ObjectTypeDB::bind_method("_http_request_completed",&EditorAssetLibrary::_http_request_completed); @@ -1273,6 +1295,11 @@ void EditorAssetLibrary::_bind_methods() { ObjectTypeDB::bind_method("_repository_changed",&EditorAssetLibrary::_repository_changed); ObjectTypeDB::bind_method("_support_toggled",&EditorAssetLibrary::_support_toggled); ObjectTypeDB::bind_method("_rerun_search",&EditorAssetLibrary::_rerun_search); + ObjectTypeDB::bind_method("_install_external_asset",&EditorAssetLibrary::_install_external_asset); + + + + ADD_SIGNAL(MethodInfo("install_asset",PropertyInfo(Variant::STRING,"zip_path"),PropertyInfo(Variant::STRING,"name"))); } @@ -1366,7 +1393,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { repository = memnew( OptionButton ); repository->add_item("Godot"); - repository->set_item_metadata(0, "http://godotengine.org/asset-library/api"); + repository->set_item_metadata(0, "https://godotengine.org/asset-library/api"); repository->add_item("Localhost"); // TODO: Maybe remove? repository->set_item_metadata(1, "http://127.0.0.1/asset-library/api"); repository->connect("item_selected",this,"_repository_changed"); diff --git a/tools/editor/asset_library_editor_plugin.h b/tools/editor/asset_library_editor_plugin.h index 89663aa00b..fe40255af9 100644 --- a/tools/editor/asset_library_editor_plugin.h +++ b/tools/editor/asset_library_editor_plugin.h @@ -155,6 +155,8 @@ class EditorAssetLibraryItemDownload : public PanelContainer { int asset_id; + bool external_install; + EditorAssetInstaller *asset_installer; void _close(); @@ -168,6 +170,7 @@ protected: static void _bind_methods(); public: + void set_external_install(bool p_enable) { external_install=p_enable; } int get_asset_id() { return asset_id; } void configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url, const String& p_sha256_hash); EditorAssetLibraryItemDownload(); @@ -301,6 +304,8 @@ class EditorAssetLibrary : public PanelContainer { void _repository_changed(int p_repository_id); void _support_toggled(int p_support); + void _install_external_asset(String p_zip_path,String p_title); + friend class EditorAssetLibraryItemDescription; friend class EditorAssetLibraryItem; protected: diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 644478923c..71ae171dfe 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -32,6 +32,7 @@ #include "scene/gui/separator.h" #include "scene/resources/dynamic_font.h" #include "os/keyboard.h" +#include "tools/editor/editor_scale.h" void GotoLineDialog::popup_find_line(TextEdit *p_edit) { @@ -984,36 +985,47 @@ void CodeTextEditor::_text_editor_input_event(const InputEvent& p_event) { if (mb.pressed && mb.mod.command) { if (mb.button_index==BUTTON_WHEEL_UP) { - - font_resize_val+=1; - - if (font_resize_timer->get_time_left()==0) - font_resize_timer->start(); - + _zoom_in(); } else if (mb.button_index==BUTTON_WHEEL_DOWN) { - - font_resize_val-=1; - - if (font_resize_timer->get_time_left()==0) - font_resize_timer->start(); + _zoom_out(); } } } else if (p_event.type==InputEvent::KEY) { - const InputEventKey& k=p_event.key; + if (p_event.key.pressed) { + if (ED_IS_SHORTCUT("script_editor/zoom_in", p_event)) { + _zoom_in(); + } + if (ED_IS_SHORTCUT("script_editor/zoom_out", p_event)) { + _zoom_out(); + } + if (ED_IS_SHORTCUT("script_editor/reset_zoom", p_event)) { + _reset_zoom(); + } + } + } +} - if (k.pressed && k.mod.command) { +void CodeTextEditor::_zoom_in() { + font_resize_val+=1; - if (k.scancode==KEY_0) { // reset source font size to default + if (font_resize_timer->get_time_left()==0) + font_resize_timer->start(); +} - Ref<DynamicFont> font = text_editor->get_font("font"); +void CodeTextEditor::_zoom_out() { + font_resize_val-=1; - if (font.is_valid()) { - EditorSettings::get_singleton()->set("global/source_font_size",14); - font->set_size(14); - } - } - } + if (font_resize_timer->get_time_left()==0) + font_resize_timer->start(); +} + +void CodeTextEditor::_reset_zoom() { + Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default + + if (font.is_valid()) { + EditorSettings::get_singleton()->set("global/source_font_size",14); + font->set_size(14); } } @@ -1149,6 +1161,10 @@ void CodeTextEditor::_bind_methods() { CodeTextEditor::CodeTextEditor() { + ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD|KEY_EQUAL); + ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD|KEY_MINUS); + ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD|KEY_0); + find_replace_bar = memnew( FindReplaceBar ); add_child(find_replace_bar); find_replace_bar->set_h_size_flags(SIZE_EXPAND_FILL); @@ -1198,6 +1214,10 @@ CodeTextEditor::CodeTextEditor() { line_col = memnew( Label ); status_bar->add_child(line_col); line_col->set_valign(Label::VALIGN_CENTER); + line_col->set_autowrap(true); + line_col->set_v_size_flags(SIZE_FILL); + line_col->set_custom_minimum_size(Size2(100,1)*EDSCALE); + status_bar->add_child( memnew( Label ) ); //to keep the height if the other labels are not visible text_editor->connect("input_event", this,"_text_editor_input_event"); diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h index bdfd295ded..7983c46f7a 100644 --- a/tools/editor/code_editor.h +++ b/tools/editor/code_editor.h @@ -214,6 +214,9 @@ class CodeTextEditor : public VBoxContainer { void _font_resize_timeout(); void _text_editor_input_event(const InputEvent& p_event); + void _zoom_in(); + void _zoom_out(); + void _reset_zoom(); protected: diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index faaae4360b..bdc420c70f 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -309,6 +309,7 @@ ConnectDialog::ConnectDialog() { tree = memnew(SceneTreeEditor(false)); + tree->get_scene_tree()->connect("item_activated",this,"_ok"); vbc_left->add_margin_child(TTR("Connect To Node:"),tree,true); diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index 5275e1beeb..210b799f3d 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -42,12 +42,13 @@ void CreateDialog::popup(bool p_dontclear) { - popup_centered_ratio(0.6); + popup_centered_ratio(); if (p_dontclear) search_box->select_all(); else search_box->clear(); search_box->grab_focus(); + _update_search(); @@ -165,9 +166,10 @@ void CreateDialog::_update_search() { if (!ObjectTypeDB::can_instance(type)) continue; // cant create what can't be instanced - if (search_box->get_text()=="") + + if (search_box->get_text()=="") { add_type(type,types,root,&to_select); - else { + } else { bool found=false; String type=I->get(); @@ -186,7 +188,7 @@ void CreateDialog::_update_search() { add_type(I->get(),types,root,&to_select); } - if (EditorNode::get_editor_data().get_custom_types().has(type)) { + if (EditorNode::get_editor_data().get_custom_types().has(type) && ObjectTypeDB::is_type(type, base_type)) { //there are custom types based on this... cool. //print_line("there are custom types"); @@ -198,6 +200,7 @@ void CreateDialog::_update_search() { if (!show) continue; + if (!types.has(type)) add_type(type,types,root,&to_select); @@ -216,7 +219,7 @@ void CreateDialog::_update_search() { } - if (!to_select && (search_box->get_text()=="" || ct[i].name.findn(search_box->get_text())!=-1)) { + if (!to_select) { to_select=item; } @@ -246,7 +249,6 @@ void CreateDialog::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { connect("confirmed",this,"_confirmed"); - _update_search(); } if (p_what==NOTIFICATION_EXIT_TREE) { diff --git a/tools/editor/dependency_editor.cpp b/tools/editor/dependency_editor.cpp index ad2eb57f00..049bcefc75 100644 --- a/tools/editor/dependency_editor.cpp +++ b/tools/editor/dependency_editor.cpp @@ -80,8 +80,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String continue; String path = efsd->get_file_path(i); - Map<String,String> &ss = candidates[file]; - for(Map<String,String>::Element *E=candidates[file].front();E;E=E->next()) { @@ -420,7 +418,7 @@ void DependencyRemoveDialog::show(const Vector<String> &to_erase) { exist=false; owners->clear(); files.clear(); - TreeItem *root=owners->create_item(); + owners->create_item(); // root for(int i=0;i<to_erase.size();i++) { files[to_erase[i]]=NULL; } diff --git a/tools/editor/editor_asset_installer.cpp b/tools/editor/editor_asset_installer.cpp index ec36773d8d..b6051886c0 100644 --- a/tools/editor/editor_asset_installer.cpp +++ b/tools/editor/editor_asset_installer.cpp @@ -317,9 +317,11 @@ void EditorAssetInstaller::ok_pressed() { } msg+=failed_files[i]; } - EditorNode::get_singleton()->show_warning(msg); + if (EditorNode::get_singleton() != NULL) + EditorNode::get_singleton()->show_warning(msg); } else { - EditorNode::get_singleton()->show_warning("Package Installed Successfully!","Success!"); + if (EditorNode::get_singleton() != NULL) + EditorNode::get_singleton()->show_warning("Package Installed Successfully!","Success!"); } diff --git a/tools/editor/editor_autoload_settings.cpp b/tools/editor/editor_autoload_settings.cpp new file mode 100644 index 0000000000..97062b1480 --- /dev/null +++ b/tools/editor/editor_autoload_settings.cpp @@ -0,0 +1,616 @@ +/*************************************************************************/ +/* editor_autoload_settings.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 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_autoload_settings.h" + +#include "globals.h" +#include "global_constants.h" + +#include "editor_node.h" + +#define PREVIEW_LIST_MAX_SIZE 10 + +void EditorAutoloadSettings::_notification(int p_what) { + + if (p_what == NOTIFICATION_ENTER_TREE) { + + List<String> afn; + ResourceLoader::get_recognized_extensions_for_type("Script", &afn); + ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn); + + EditorFileDialog *file_dialog = autoload_add_path->get_file_dialog(); + + for (List<String>::Element *E = afn.front(); E; E = E->next()) { + + file_dialog->add_filter("*." + E->get()); + } + } +} + +bool EditorAutoloadSettings::_autoload_name_is_valid(const String& p_name, String* r_error) { + + if (!p_name.is_valid_identifier()) { + if (r_error) + *r_error = TTR("Invalid name.") + "\n" + TTR("Valid characters:")+" a-z, A-Z, 0-9 or _"; + + return false; + } + + if (ObjectTypeDB::type_exists(p_name)) { + if (r_error) + *r_error = TTR("Invalid name. Must not collide with an existing engine class name."); + + return false; + } + + for (int i = 0; i < Variant::VARIANT_MAX; i++) { + if (Variant::get_type_name( Variant::Type(i) ) == p_name) { + if (r_error) + *r_error = TTR("Invalid name. Must not collide with an existing buit-in type name."); + + return false; + } + } + + for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) { + if (GlobalConstants::get_global_constant_name(i) == p_name) { + if (r_error) + *r_error = TTR("Invalid name. Must not collide with an existing global constant name."); + + return false; + } + } + + return true; +} + +void EditorAutoloadSettings::_autoload_add() { + + String name = autoload_add_name->get_text(); + + String error; + if (!_autoload_name_is_valid(name, &error)) { + EditorNode::get_singleton()->show_warning(error); + return; + } + + String path = autoload_add_path->get_line_edit()->get_text(); + if (!FileAccess::exists(path)) { + EditorNode::get_singleton()->show_warning(TTR("Invalid Path.") + "\n" + TTR("File does not exist.")); + return; + } + + if (!path.begins_with("res://")) { + EditorNode::get_singleton()->show_warning(TTR("Invalid Path.") + "\n"+ TTR("Not in resource path.")); + return; + } + + name = "autoload/" + name; + + UndoRedo* undo_redo = EditorNode::get_singleton()->get_undo_redo(); + + undo_redo->create_action(TTR("Add AutoLoad")); + undo_redo->add_do_property(Globals::get_singleton(), name, "*" + path); + undo_redo->add_do_method(Globals::get_singleton(), "set_persisting", name, true); + + if (Globals::get_singleton()->has(name)) { + undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name)); + } else { + undo_redo->add_undo_property(Globals::get_singleton(), name, Variant()); + } + + undo_redo->add_do_method(this, "update_autoload"); + undo_redo->add_undo_method(this, "update_autoload"); + + undo_redo->add_do_method(this, "emit_signal", autoload_changed); + undo_redo->add_undo_method(this, "emit_signal", autoload_changed); + + undo_redo->commit_action(); + + autoload_add_path->get_line_edit()->set_text(""); + autoload_add_name->set_text(""); +} + +void EditorAutoloadSettings::_autoload_selected() { + + TreeItem *ti = tree->get_selected(); + + if (!ti) + return; + + selected_autoload = "autoload/" + ti->get_text(0); +} + +void EditorAutoloadSettings::_autoload_edited() { + + if (updating_autoload) + return; + + TreeItem *ti = tree->get_edited(); + int column = tree->get_edited_column(); + + UndoRedo *undo_redo = EditorNode::get_undo_redo(); + + if (column == 0) { + String name = ti->get_text(0); + String old_name = selected_autoload.get_slice("/", 1); + + if (name == old_name) + return; + + String error; + if (!_autoload_name_is_valid(name, &error)) { + ti->set_text(0, old_name); + EditorNode::get_singleton()->show_warning(error); + return; + } + + if (Globals::get_singleton()->has("autoload/" + name)) { + ti->set_text(0, old_name); + EditorNode::get_singleton()->show_warning(vformat(TTR("Autoload '%s' already exists!"), name)); + return; + } + + updating_autoload = true; + + name = "autoload/" + name; + + bool persisting = Globals::get_singleton()->get(selected_autoload); + int order = Globals::get_singleton()->get(selected_autoload); + String path = Globals::get_singleton()->get(selected_autoload); + + undo_redo->create_action(TTR("Rename Autoload")); + + undo_redo->add_do_property(Globals::get_singleton(), name, path); + undo_redo->add_do_method(Globals::get_singleton(), "set_persisting", name, persisting); + undo_redo->add_do_method(Globals::get_singleton(), "set_order", name, order); + undo_redo->add_do_method(Globals::get_singleton(), "clear", selected_autoload); + + undo_redo->add_undo_property(Globals::get_singleton(), selected_autoload, path); + undo_redo->add_undo_method(Globals::get_singleton(), "set_persisting", selected_autoload, persisting); + undo_redo->add_undo_method(Globals::get_singleton(), "set_order", selected_autoload, order); + undo_redo->add_undo_method(Globals::get_singleton(), "clear", name); + + undo_redo->add_do_method(this, "update_autoload"); + undo_redo->add_undo_method(this, "update_autoload"); + + undo_redo->add_do_method(this, "emit_signal", autoload_changed); + undo_redo->add_undo_method(this, "emit_signal", autoload_changed); + + undo_redo->commit_action(); + + selected_autoload = name; + } else if (column == 2) { + updating_autoload = true; + + bool checked = ti->is_checked(2); + String base = "autoload/" + ti->get_text(0); + + int order = Globals::get_singleton()->get_order(base); + String path = Globals::get_singleton()->get(base); + + if (path.begins_with("*")) + path = path.substr(1, path.length()); + + if (checked) + path = "*" + path; + + undo_redo->create_action(TTR("Toggle AutoLoad Globals")); + + undo_redo->add_do_property(Globals::get_singleton(), base, path); + undo_redo->add_undo_property(Globals::get_singleton(), base, Globals::get_singleton()->get(base)); + + undo_redo->add_do_method(Globals::get_singleton(),"set_order", base, order); + undo_redo->add_undo_method(Globals::get_singleton(),"set_order", base, order); + + undo_redo->add_do_method(this, "update_autoload"); + undo_redo->add_undo_method(this, "update_autoload"); + + undo_redo->add_do_method(this, "emit_signal", autoload_changed); + undo_redo->add_undo_method(this, "emit_signal", autoload_changed); + + undo_redo->commit_action(); + } + + updating_autoload = false; +} + +void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_column, int p_button) { + + TreeItem *ti = p_item->cast_to<TreeItem>(); + + String name = "autoload/" + ti->get_text(0); + + UndoRedo *undo_redo = EditorNode::get_undo_redo(); + + switch (p_button) { + + case BUTTON_MOVE_UP: + case BUTTON_MOVE_DOWN: { + + TreeItem *swap = NULL; + + if (p_button == BUTTON_MOVE_UP) { + swap = ti->get_prev(); + } else { + swap = ti->get_next(); + } + + if (!swap) + return; + + String swap_name = "autoload/" + swap->get_text(0); + + int order = Globals::get_singleton()->get_order(name); + int swap_order = Globals::get_singleton()->get_order(swap_name); + + undo_redo->create_action(TTR("Move Autoload")); + + undo_redo->add_do_method(Globals::get_singleton(), "set_order", name, swap_order); + undo_redo->add_undo_method(Globals::get_singleton(), "set_order", name, order); + + undo_redo->add_do_method(Globals::get_singleton(), "set_order", swap_name, order); + undo_redo->add_undo_method(Globals::get_singleton(), "set_order", swap_name, swap_order); + + undo_redo->add_do_method(this, "update_autoload"); + undo_redo->add_undo_method(this, "update_autoload"); + + undo_redo->add_do_method(this, "emit_signal", autoload_changed); + undo_redo->add_undo_method(this, "emit_signal", autoload_changed); + + undo_redo->commit_action(); + } break; + case BUTTON_DELETE: { + + int order = Globals::get_singleton()->get_order(name); + + undo_redo->create_action(TTR("Remove Autoload")); + + undo_redo->add_do_property(Globals::get_singleton(), name, Variant()); + + undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name)); + undo_redo->add_undo_method(Globals::get_singleton(), "set_persisting", name, true); + undo_redo->add_undo_method(Globals::get_singleton(), "set_order", order); + + undo_redo->add_do_method(this, "update_autoload"); + undo_redo->add_undo_method(this, "update_autoload"); + + undo_redo->add_do_method(this, "emit_signal", autoload_changed); + undo_redo->add_undo_method(this, "emit_signal", autoload_changed); + + undo_redo->commit_action(); + } break; + } +} + +void EditorAutoloadSettings::_autoload_file_callback(const String& p_path) { + + autoload_add_name->set_text(p_path.get_file().basename()); +} + +void EditorAutoloadSettings::update_autoload() { + + if (updating_autoload) + return; + + updating_autoload = true; + + autoload_cache.clear(); + + tree->clear(); + TreeItem *root = tree->create_item(); + + List<PropertyInfo> props; + Globals::get_singleton()->get_property_list(&props); + + for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + + const PropertyInfo &pi = E->get(); + + if (!pi.name.begins_with("autoload/")) + continue; + + String name = pi.name.get_slice("/", 1); + String path = Globals::get_singleton()->get(pi.name); + + if (name.empty()) + continue; + + AutoLoadInfo info; + info.name = pi.name; + info.order = Globals::get_singleton()->get_order(pi.name); + + autoload_cache.push_back(info); + + bool global = false; + + if (path.begins_with("*")) { + global = true; + path = path.substr(1, path.length()); + } + + TreeItem *item = tree->create_item(root); + item->set_text(0, name); + item->set_editable(0, true); + + item->set_text(1, path); + item->set_selectable(1, false); + + item->set_cell_mode(2, TreeItem::CELL_MODE_CHECK); + item->set_editable(2, true); + item->set_text(2, TTR("Enable")); + item->set_checked(2, global); + + item->add_button(3, get_icon("MoveUp","EditorIcons"), BUTTON_MOVE_UP); + item->add_button(3, get_icon("MoveDown","EditorIcons"), BUTTON_MOVE_DOWN); + item->add_button(3, get_icon("Del","EditorIcons"), BUTTON_DELETE); + item->set_selectable(3, false); + } + + updating_autoload = false; +} + +Variant EditorAutoloadSettings::get_drag_data_fw(const Point2& p_point, Control *p_control) { + + if (autoload_cache.size() <= 1) + return false; + + StringArray autoloads; + + TreeItem *next = tree->get_next_selected(NULL); + + while (next) { + autoloads.push_back(next->get_text(0)); + next = tree->get_next_selected(next); + } + + if (autoloads.size() == 0 || autoloads.size() == autoload_cache.size()) + return Variant(); + + VBoxContainer *preview = memnew( VBoxContainer ); + + int max_size = MIN(PREVIEW_LIST_MAX_SIZE, autoloads.size()); + + for (int i = 0; i < max_size; i++) { + Label *label = memnew( Label(autoloads[i]) ); + label->set_self_opacity(Math::lerp(1, 0, float(i)/PREVIEW_LIST_MAX_SIZE)); + + preview->add_child(label); + } + + tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN); + tree->set_drag_preview(preview); + + Dictionary drop_data; + drop_data["type"] = "autoload"; + drop_data["autoloads"] = autoloads; + + return drop_data; +} + +bool EditorAutoloadSettings::can_drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_control) const { + if (updating_autoload) + return false; + + Dictionary drop_data = p_data; + + if (!drop_data.has("type")) + return false; + + if (drop_data.has("type")) { + TreeItem *ti = tree->get_item_at_pos(p_point); + + if (!ti) + return false; + + int section = tree->get_drop_section_at_pos(p_point); + + if (section < -1) + return false; + + return true; + } + + return false; +} + +void EditorAutoloadSettings::drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_control) { + + TreeItem *ti = tree->get_item_at_pos(p_point); + + if (!ti) + return; + + int section = tree->get_drop_section_at_pos(p_point); + + if (section < -1) + return; + + String name; + bool move_to_back = false; + + if (section < 0) { + name = ti->get_text(0); + } else if (ti->get_next()) { + name = ti->get_next()->get_text(0); + } else { + name = ti->get_text(0); + move_to_back = true; + } + + int order = Globals::get_singleton()->get_order("autoload/" + name); + + AutoLoadInfo aux; + List<AutoLoadInfo>::Element *E = NULL; + + if (!move_to_back) { + aux.order = order; + E = autoload_cache.find(aux); + } + + Dictionary drop_data = p_data; + StringArray autoloads = drop_data["autoloads"]; + + Vector<int> orders; + orders.resize(autoload_cache.size()); + + for (int i = 0; i < autoloads.size(); i++) { + aux.order = Globals::get_singleton()->get_order("autoload/" + autoloads[i]); + + List<AutoLoadInfo>::Element *I = autoload_cache.find(aux); + + if (move_to_back) { + autoload_cache.move_to_back(I); + } else if (E != I) { + autoload_cache.move_before(I, E); + } else if (E->next()) { + E = E->next(); + } else { + break; + } + } + + int i = 0; + + for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { + orders[i++] = E->get().order; + } + + orders.sort(); + + UndoRedo *undo_redo = EditorNode::get_undo_redo(); + + undo_redo->create_action(TTR("Rearrange Autoloads")); + + i = 0; + + for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { + undo_redo->add_do_method(Globals::get_singleton(), "set_order", E->get().name, orders[i++]); + undo_redo->add_undo_method(Globals::get_singleton(), "set_order", E->get().name, E->get().order); + } + + orders.clear(); + + undo_redo->add_do_method(this, "update_autoload"); + undo_redo->add_undo_method(this, "update_autoload"); + + undo_redo->add_do_method(this, "emit_signal", autoload_changed); + undo_redo->add_undo_method(this, "emit_signal", autoload_changed); + + undo_redo->commit_action(); +} + +void EditorAutoloadSettings::_bind_methods() { + + ObjectTypeDB::bind_method("_autoload_add", &EditorAutoloadSettings::_autoload_add); + ObjectTypeDB::bind_method("_autoload_selected", &EditorAutoloadSettings::_autoload_selected); + ObjectTypeDB::bind_method("_autoload_edited", &EditorAutoloadSettings::_autoload_edited); + ObjectTypeDB::bind_method("_autoload_button_pressed", &EditorAutoloadSettings::_autoload_button_pressed); + ObjectTypeDB::bind_method("_autoload_file_callback", &EditorAutoloadSettings::_autoload_file_callback); + + ObjectTypeDB::bind_method("get_drag_data_fw", &EditorAutoloadSettings::get_drag_data_fw); + ObjectTypeDB::bind_method("can_drop_data_fw", &EditorAutoloadSettings::can_drop_data_fw); + ObjectTypeDB::bind_method("drop_data_fw", &EditorAutoloadSettings::drop_data_fw); + + ObjectTypeDB::bind_method("update_autoload", &EditorAutoloadSettings::update_autoload); + + ADD_SIGNAL(MethodInfo("autoload_changed")); +} + +EditorAutoloadSettings::EditorAutoloadSettings() { + + autoload_changed = "autoload_changed"; + + updating_autoload = false; + selected_autoload = ""; + + HBoxContainer *hbc = memnew( HBoxContainer ); + add_child(hbc); + + VBoxContainer *vbc_path = memnew( VBoxContainer ); + vbc_path->set_h_size_flags(SIZE_EXPAND_FILL); + + autoload_add_path = memnew( EditorLineEditFileChooser ); + autoload_add_path->set_h_size_flags(SIZE_EXPAND_FILL); + + autoload_add_path->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE); + autoload_add_path->get_file_dialog()->connect("file_selected", this, "_autoload_file_callback"); + + vbc_path->add_margin_child(TTR("Path:"), autoload_add_path); + hbc->add_child(vbc_path); + + VBoxContainer *vbc_name = memnew( VBoxContainer ); + vbc_name->set_h_size_flags(SIZE_EXPAND_FILL); + + HBoxContainer *hbc_name = memnew( HBoxContainer ); + + autoload_add_name = memnew( LineEdit ); + autoload_add_name->set_h_size_flags(SIZE_EXPAND_FILL); + hbc_name->add_child(autoload_add_name); + + Button *add_autoload = memnew( Button ); + add_autoload->set_text(TTR("Add")); + hbc_name->add_child(add_autoload); + add_autoload->connect("pressed", this, "_autoload_add"); + + vbc_name->add_margin_child(TTR("Node Name:"), hbc_name); + hbc->add_child(vbc_name); + + tree = memnew( Tree ); + tree->set_hide_root(true); + tree->set_select_mode(Tree::SELECT_MULTI); + tree->set_single_select_cell_editing_only_when_already_selected(true); + + tree->set_drag_forwarding(this); + + tree->set_columns(4); + tree->set_column_titles_visible(true); + + tree->set_column_title(0,TTR("Name")); + tree->set_column_expand(0,true); + tree->set_column_min_width(0,100); + + tree->set_column_title(1,TTR("Path")); + tree->set_column_expand(1,true); + tree->set_column_min_width(1,100); + + tree->set_column_title(2,TTR("Singleton")); + tree->set_column_expand(2,false); + tree->set_column_min_width(2,80); + + tree->set_column_expand(3,false); + tree->set_column_min_width(3,80); + + tree->connect("cell_selected", this, "_autoload_selected"); + tree->connect("item_edited", this, "_autoload_edited"); + tree->connect("button_pressed", this, "_autoload_button_pressed"); + + add_margin_child(TTR("List:"), tree, true); +} + diff --git a/tools/editor/import_settings.h b/tools/editor/editor_autoload_settings.h index 5a383a1a1a..b61c44b9c2 100644 --- a/tools/editor/import_settings.h +++ b/tools/editor/editor_autoload_settings.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* import_settings.h */ +/* editor_autoload_settings.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,57 +26,69 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef IMPORT_SETTINGS_H -#define IMPORT_SETTINGS_H -#include "object.h" -#include "scene/gui/dialogs.h" +#ifndef EDITOR_AUTOLOAD_SETTINGS_H +#define EDITOR_AUTOLOAD_SETTINGS_H + #include "scene/gui/tree.h" -#include "scene/gui/label.h" -#include "scene/gui/option_button.h" -#include "scene/gui/line_edit.h" -#include "scene/gui/file_dialog.h" -#include "scene/gui/progress_bar.h" -#include "scene/gui/slider.h" -#include "scene/gui/spin_box.h" -#include "scene/resources/mesh.h" -#include "editor_import_export.h" -#include "editor_file_system.h" -#include "editor_dir_dialog.h" -class EditorNode; - - -class ImportSettingsDialog : public ConfirmationDialog { - - OBJ_TYPE(ImportSettingsDialog,ConfirmationDialog); - - TreeItem *edited; - EditorNode *editor; + +#include "editor_file_dialog.h" + +class EditorAutoloadSettings : public VBoxContainer { + + OBJ_TYPE( EditorAutoloadSettings, VBoxContainer ); + + enum { + BUTTON_MOVE_UP, + BUTTON_MOVE_DOWN, + BUTTON_DELETE + }; + + String autoload_changed; + + struct AutoLoadInfo { + String name; + int order; + + bool operator==(const AutoLoadInfo& p_info) { + return order == p_info.order; + } + }; + + List<AutoLoadInfo> autoload_cache; + + bool updating_autoload; + int number_of_autoloads; + String selected_autoload; + Tree *tree; - bool updating; + EditorLineEditFileChooser *autoload_add_path; + LineEdit *autoload_add_name; - void _button_pressed(Object *p_button, int p_col, int p_id); - void _item_pressed(int p_idx); - bool _generate_fs(TreeItem *p_parent,EditorFileSystemDirectory *p_dir); + bool _autoload_name_is_valid(const String& p_string, String *r_error = NULL); - String texformat; + void _autoload_add(); + void _autoload_selected(); + void _autoload_edited(); + void _autoload_button_pressed(Object *p_item, int p_column, int p_button); + void _autoload_file_callback(const String& p_path); - void _item_edited(); - virtual void ok_pressed(); + Variant get_drag_data_fw(const Point2& p_point, Control *p_from); + bool can_drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_from) const; + void drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_from); protected: - void _notification(int p_what); static void _bind_methods(); -public: - void update_tree(); +public: + void update_autoload(); - void popup_import_settings(); - ImportSettingsDialog(EditorNode *p_editor); + EditorAutoloadSettings(); }; -#endif // IMPORT_SETTINGS_H +#endif + diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index 4c4fecdd83..8d3fd6c9c2 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -326,6 +326,13 @@ Dictionary EditorData::get_editor_states() const { } +Dictionary EditorData::get_scene_editor_states(int p_idx) const +{ + ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),Dictionary()); + EditedScene es = edited_scene[p_idx]; + return es.editor_states; +} + void EditorData::set_editor_states(const Dictionary& p_states) { List<Variant> keys; @@ -565,6 +572,8 @@ bool EditorData::check_and_update_scene(int p_idx) { bool must_reload = _find_updated_instances(edited_scene[p_idx].root,edited_scene[p_idx].root,checked_scenes); + print_line("MUST RELOAD? "+itos(must_reload)); + if (must_reload) { Ref<PackedScene> pscene; pscene.instance(); @@ -611,11 +620,14 @@ void EditorData::set_edited_scene(int p_idx){ current_edited_scene=p_idx; //swap } -Node* EditorData::get_edited_scene_root(){ - - ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),NULL); - - return edited_scene[current_edited_scene].root; +Node* EditorData::get_edited_scene_root(int p_idx){ + if (p_idx < 0) { + ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),NULL); + return edited_scene[current_edited_scene].root; + } else { + ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),NULL); + return edited_scene[p_idx].root; + } } void EditorData::set_edited_scene_root(Node* p_root) { @@ -628,9 +640,14 @@ int EditorData::get_edited_scene_count() const { return edited_scene.size(); } -void EditorData::set_edited_scene_version(uint64_t version) { +void EditorData::set_edited_scene_version(uint64_t version, int scene_idx) { ERR_FAIL_INDEX(current_edited_scene,edited_scene.size()); - edited_scene[current_edited_scene].version=version; + if (scene_idx < 0) { + edited_scene[current_edited_scene].version=version; + } else { + ERR_FAIL_INDEX(scene_idx,edited_scene.size()); + edited_scene[scene_idx].version=version; + } } @@ -756,12 +773,19 @@ void EditorData::set_edited_scene_import_metadata(Ref<ResourceImportMetadata> p_ } -Ref<ResourceImportMetadata> EditorData::get_edited_scene_import_metadata() const{ +Ref<ResourceImportMetadata> EditorData::get_edited_scene_import_metadata(int idx) const{ ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),Ref<ResourceImportMetadata>()); - return edited_scene[current_edited_scene].medatata; + if(idx<0) { + return edited_scene[current_edited_scene].medatata; + } else { + ERR_FAIL_INDEX_V(idx,edited_scene.size(),Ref<ResourceImportMetadata>()); + return edited_scene[idx].medatata; + } } + + void EditorData::clear_edited_scenes() { for(int i=0;i<edited_scene.size();i++) { diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h index 319155655d..a0b716f560 100644 --- a/tools/editor/editor_data.h +++ b/tools/editor/editor_data.h @@ -156,6 +156,7 @@ public: void paste_object_params(Object *p_object); Dictionary get_editor_states() const; + Dictionary get_scene_editor_states(int p_idx) const; void set_editor_states(const Dictionary& p_states); void get_editor_breakpoints(List<String> *p_breakpoints); void clear_editor_states(); @@ -184,15 +185,15 @@ public: void set_edited_scene(int p_idx); void set_edited_scene_root(Node* p_root); void set_edited_scene_import_metadata(Ref<ResourceImportMetadata> p_mdata); - Ref<ResourceImportMetadata> get_edited_scene_import_metadata() const; + Ref<ResourceImportMetadata> get_edited_scene_import_metadata(int p_idx = -1) const; int get_edited_scene() const; - Node* get_edited_scene_root(); + Node* get_edited_scene_root(int p_idx = -1); int get_edited_scene_count() const; String get_scene_title(int p_idx) const; String get_scene_path(int p_idx) const; String get_scene_type(int p_idx) const; Ref<Script> get_scene_root_script(int p_idx) const; - void set_edited_scene_version(uint64_t version); + void set_edited_scene_version(uint64_t version, int p_scene_idx = -1); uint64_t get_edited_scene_version() const; uint64_t get_scene_version(int p_idx) const; void clear_edited_scenes(); diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp index a6e231cf18..f6ce7bf3f8 100644 --- a/tools/editor/editor_dir_dialog.cpp +++ b/tools/editor/editor_dir_dialog.cpp @@ -99,8 +99,14 @@ void EditorDirDialog::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { reload(); - tree->connect("item_collapsed",this,"_item_collapsed",varray(),CONNECT_DEFERRED); - EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"reload"); + + if (!tree->is_connected("item_collapsed",this,"_item_collapsed")) { + tree->connect("item_collapsed",this,"_item_collapsed",varray(),CONNECT_DEFERRED); + } + + if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed",this,"reload")) { + EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"reload"); + } } @@ -185,10 +191,14 @@ void EditorDirDialog::ok_pressed() { void EditorDirDialog::_make_dir() { TreeItem *ti=tree->get_selected(); - if (!ti) + if (!ti) { + mkdirerr->set_text("Please select a base directory first"); + mkdirerr->popup_centered_minsize(); return; + } makedialog->popup_centered_minsize(Size2(250,80)); + makedirname->grab_focus(); } void EditorDirDialog::_make_dir_confirm() { @@ -198,9 +208,11 @@ void EditorDirDialog::_make_dir_confirm() { return; String dir = ti->get_metadata(0); + DirAccess *d = DirAccess::open(dir); ERR_FAIL_COND(!d); Error err = d->make_dir(makedirname->get_text()); + if (err!=OK) { mkdirerr->popup_centered_minsize(Size2(250,80)); } else { diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index e68a53659b..b8abd1d32c 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -144,11 +144,11 @@ void EditorFileDialog::_unhandled_input(const InputEvent& p_event) { dir->grab_focus(); handled=true; } - if (ED_IS_SHORTCUT("file_dialog/mode_favorite_up", p_event)) { + if (ED_IS_SHORTCUT("file_dialog/move_favorite_up", p_event)) { _favorite_move_up(); handled=true; } - if (ED_IS_SHORTCUT("file_dialog/mode_favorite_down", p_event)) { + if (ED_IS_SHORTCUT("file_dialog/move_favorite_down", p_event)) { _favorite_move_down(); handled=true; } @@ -1290,14 +1290,14 @@ EditorFileDialog::EditorFileDialog() { ED_SHORTCUT("file_dialog/go_back", TTR("Go Back"), KEY_MASK_ALT|KEY_LEFT); ED_SHORTCUT("file_dialog/go_forward", TTR("Go Forward"), KEY_MASK_ALT|KEY_RIGHT); ED_SHORTCUT("file_dialog/go_up", TTR("Go Up"), KEY_MASK_ALT|KEY_UP); - ED_SHORTCUT("file_dialog/refresh", TTR("Refresh"), KEY_MASK_CMD|KEY_F5); // ctrl + f5 else it launches the game as well.. + ED_SHORTCUT("file_dialog/refresh", TTR("Refresh"), KEY_F5); ED_SHORTCUT("file_dialog/toggle_hidden_files", TTR("Toggle Hidden Files"), KEY_MASK_CMD|KEY_H); ED_SHORTCUT("file_dialog/toggle_favorite", TTR("Toggle Favorite"), KEY_MASK_ALT|KEY_F); ED_SHORTCUT("file_dialog/toggle_mode", TTR("Toggle Mode"), KEY_MASK_ALT|KEY_V); ED_SHORTCUT("file_dialog/create_folder", TTR("Create Folder"), KEY_MASK_CMD|KEY_N); ED_SHORTCUT("file_dialog/focus_path", TTR("Focus Path"), KEY_MASK_CMD|KEY_D); - ED_SHORTCUT("file_dialog/mode_favorite_up", TTR("Mode Favorite Up"), KEY_MASK_CMD|KEY_UP); - ED_SHORTCUT("file_dialog/mode_favorite_down", TTR("Mode Favorite Down"), KEY_MASK_CMD|KEY_DOWN); + ED_SHORTCUT("file_dialog/move_favorite_up", TTR("Move Favorite Up"), KEY_MASK_CMD|KEY_UP); + ED_SHORTCUT("file_dialog/move_favorite_down", TTR("Move Favorite Down"), KEY_MASK_CMD|KEY_DOWN); HBoxContainer *pathhb = memnew( HBoxContainer ); diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index c5c92b5228..cb7cefea26 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -34,6 +34,7 @@ #include "editor_node.h" #include "io/resource_saver.h" #include "editor_settings.h" +#include "editor_resource_preview.h" EditorFileSystem *EditorFileSystem::singleton=NULL; @@ -621,31 +622,40 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess int total = dirs.size()+files.size(); int idx=0; + for (List<String>::Element *E=dirs.front();E;E=E->next(),idx++) { if (da->change_dir(E->get())==OK) { - EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory ); + String d = da->get_current_dir(); - efd->parent=p_dir; - efd->name=E->get(); + if (d==cd || !d.begins_with(cd)) { + da->change_dir(cd); //avoid recursion + } else { - _scan_new_dir(efd,da,p_progress.get_sub(idx,total)); - int idx=0; - for(int i=0;i<p_dir->subdirs.size();i++) { + EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory ); - if (efd->name<p_dir->subdirs[i]->name) - break; - idx++; - } - if (idx==p_dir->subdirs.size()) { - p_dir->subdirs.push_back(efd); - } else { - p_dir->subdirs.insert(idx,efd); - } + efd->parent=p_dir; + efd->name=E->get(); + + _scan_new_dir(efd,da,p_progress.get_sub(idx,total)); + + int idx=0; + for(int i=0;i<p_dir->subdirs.size();i++) { + + if (efd->name<p_dir->subdirs[i]->name) + break; + idx++; + } + if (idx==p_dir->subdirs.size()) { + p_dir->subdirs.push_back(efd); + } else { + p_dir->subdirs.insert(idx,efd); + } - da->change_dir(".."); + da->change_dir(".."); + } } else { ERR_PRINTS(TTR("Cannot go into subdir:")+" "+E->get()); } @@ -821,12 +831,10 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S } } + da->list_dir_end(); memdelete(da); - - - } for(int i=0;i<p_dir->files.size();i++) { @@ -841,6 +849,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S continue; } + if (_check_meta_sources(p_dir->files[i]->meta)) { ItemAction ia; ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED; @@ -851,6 +860,8 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S } else { p_dir->files[i]->meta.sources_changed=false; } + + EditorResourcePreview::get_singleton()->check_for_invalidation(p_dir->get_file_path(i)); } for(int i=0;i<p_dir->subdirs.size();i++) { @@ -1321,6 +1332,7 @@ void EditorFileSystem::update_file(const String& p_file) { fs->files[cpos]->modified_time=FileAccess::get_modified_time(p_file); fs->files[cpos]->meta=_get_meta(p_file); + EditorResourcePreview::get_singleton()->call_deferred("check_for_invalidation",p_file); call_deferred("emit_signal","filesystem_changed"); //update later } @@ -1334,6 +1346,8 @@ void EditorFileSystem::_bind_methods() { } + + EditorFileSystem::EditorFileSystem() { diff --git a/tools/editor/editor_file_system.h b/tools/editor/editor_file_system.h index b96e947569..fb768fb358 100644 --- a/tools/editor/editor_file_system.h +++ b/tools/editor/editor_file_system.h @@ -236,6 +236,7 @@ public: EditorFileSystemDirectory *get_path(const String& p_path); String get_file_type(const String& p_file) const; EditorFileSystemDirectory* find_file(const String& p_file,int* r_index) const; + EditorFileSystem(); ~EditorFileSystem(); }; diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index 0b60db5ee3..1fc157098c 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -332,7 +332,7 @@ EditorHelpSearch::EditorHelpSearch() { register_text_enter(search_box); set_hide_on_ok(false); search_options->connect("item_activated",this,"_confirmed"); - set_title(TTR("Search Classes")); + set_title(TTR("Search Help")); // search_options->set_hide_root(true); @@ -526,6 +526,7 @@ EditorHelpIndex::EditorHelpIndex() { class_list->connect("item_activated",this,"_tree_item_selected"); get_ok()->set_text(TTR("Open")); + set_title(TTR("Search Classes")); } diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 0f8ddafb20..dee521beb3 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -168,6 +168,10 @@ void EditorNode::_update_title() { void EditorNode::_unhandled_input(const InputEvent& p_event) { + if (Node::get_viewport()->get_modal_stack_top()) + return; //ignore because of modal window + + if (p_event.type==InputEvent::KEY && p_event.key.pressed && !p_event.key.echo && !gui_base->get_viewport()->gui_has_modal_stack()) { @@ -182,6 +186,16 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) { if (ED_IS_SHORTCUT("editor/distraction_free_mode", p_event)) { set_distraction_free_mode(!get_distraction_free_mode()); } + if (ED_IS_SHORTCUT("editor/next_tab", p_event)) { + int next_tab = editor_data.get_edited_scene() + 1; + next_tab %= editor_data.get_edited_scene_count(); + _scene_tab_changed(next_tab); + } + if (ED_IS_SHORTCUT("editor/prev_tab", p_event)) { + int next_tab = editor_data.get_edited_scene() - 1; + next_tab = next_tab >= 0 ? next_tab : editor_data.get_edited_scene_count() - 1; + _scene_tab_changed(next_tab); + } switch(p_event.key.scancode) { @@ -205,18 +219,7 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) { case KEY_F6: _menu_option_confirm(RUN_PLAY_SCENE,true); break; //case KEY_F7: _menu_option_confirm(RUN_PAUSE,true); break; case KEY_F8: _menu_option_confirm(RUN_STOP,true); break;*/ - case KEY_TAB: - if (p_event.key.mod.command) { - int current_tab = editor_data.get_edited_scene(); - int tab_offset = 1; - if (p_event.key.mod.shift) - tab_offset = -1; - int next_tab = current_tab + tab_offset; - next_tab = next_tab >= 0 ? next_tab : editor_data.get_edited_scene_count() - 1; - next_tab %= editor_data.get_edited_scene_count(); - _scene_tab_changed(next_tab); - } - break; + } } @@ -505,8 +508,6 @@ void EditorNode::_rebuild_import_menu() for (int i = 0; i < editor_import_export->get_import_plugin_count(); i++) { p->add_item(editor_import_export->get_import_plugin(i)->get_visible_name(), IMPORT_PLUGIN_BASE + i); } - //p->add_separator(); - //p->add_item(TTR("Re-Import.."), SETTINGS_IMPORT); } void EditorNode::_node_renamed() { @@ -594,7 +595,6 @@ void EditorNode::save_resource(const Ref<Resource>& p_resource) { void EditorNode::save_resource_as(const Ref<Resource>& p_resource,const String& p_at_path) { file->set_mode(EditorFileDialog::MODE_SAVE_FILE); - bool relpaths = (p_resource->has_meta("__editor_relpaths__") && p_resource->get_meta("__editor_relpaths__").operator bool()); current_option=RESOURCE_SAVE_AS; List<String> extensions; @@ -704,7 +704,7 @@ void EditorNode::_get_scene_metadata(const String& p_file) { cf.instance(); Error err = cf->load(path); - if (err!=OK) + if (err!=OK || !cf->has_section("editor_states")) return; //must not exist List<String> esl; @@ -725,9 +725,9 @@ void EditorNode::_get_scene_metadata(const String& p_file) { } -void EditorNode::_set_scene_metadata(const String& p_file) { +void EditorNode::_set_scene_metadata(const String& p_file, int p_idx) { - Node *scene = editor_data.get_edited_scene_root(); + Node *scene = editor_data.get_edited_scene_root(p_idx); if (!scene) return; @@ -740,7 +740,14 @@ void EditorNode::_set_scene_metadata(const String& p_file) { Ref<ConfigFile> cf; cf.instance(); - Dictionary md = editor_data.get_editor_states(); + Dictionary md; + + if (p_idx<0 || editor_data.get_edited_scene()==p_idx) { + md = editor_data.get_editor_states(); + } else { + md = editor_data.get_scene_editor_states(p_idx); + } + List<Variant> keys; md.get_key_list(&keys); @@ -954,9 +961,9 @@ void EditorNode::_save_scene_with_preview(String p_file) { } -void EditorNode::_save_scene(String p_file) { +void EditorNode::_save_scene(String p_file, int idx) { - Node *scene = editor_data.get_edited_scene_root(); + Node *scene = editor_data.get_edited_scene_root(idx); if (!scene) { @@ -970,7 +977,7 @@ void EditorNode::_save_scene(String p_file) { editor_data.apply_changes_in_editors(); - _set_scene_metadata(p_file); + _set_scene_metadata(p_file,idx); Ref<PackedScene> sdata; @@ -1001,7 +1008,7 @@ void EditorNode::_save_scene(String p_file) { return; } - sdata->set_import_metadata(editor_data.get_edited_scene_import_metadata()); + sdata->set_import_metadata(editor_data.get_edited_scene_import_metadata(idx)); int flg=0; if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources")) flg|=ResourceSaver::FLAG_COMPRESS; @@ -1017,7 +1024,10 @@ void EditorNode::_save_scene(String p_file) { if (err==OK) { scene->set_filename( Globals::get_singleton()->localize_path(p_file) ); //EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type()); - set_current_version(editor_data.get_undo_redo().get_version()); + if (idx < 0 || idx == editor_data.get_edited_scene()) + set_current_version(editor_data.get_undo_redo().get_version()); + else + editor_data.set_edited_scene_version(0,idx); _update_title(); _update_scene_tabs(); } else { @@ -1162,7 +1172,11 @@ void EditorNode::_dialog_action(String p_file) { load_scene(p_file); } break; + case SETTINGS_PICK_MAIN_SCENE: { + Globals::get_singleton()->set("application/main_scene",p_file); + //would be nice to show the project manager opened with the hilighted field.. + } break; case FILE_SAVE_OPTIMIZED: { @@ -1544,9 +1558,10 @@ void EditorNode::_property_editor_back() { void EditorNode::_imported(Node *p_node) { - Node *scene = editor_data.get_edited_scene_root(); -// add_edited_scene(p_node); /* + Node *scene = editor_data.get_edited_scene_root(); + add_edited_scene(p_node); + if (scene) { String path = scene->get_filename(); p_node->set_filename(path); @@ -1606,6 +1621,7 @@ void EditorNode::_edit_current() { object_menu->set_disabled(true); bool is_resource = current_obj->is_type("Resource"); + bool is_node = current_obj->is_type("Node"); resource_save_button->set_disabled(!is_resource); if (is_resource) { @@ -1622,7 +1638,7 @@ void EditorNode::_edit_current() { //top_pallete->set_current_tab(1); - } else if (current_obj->is_type("Node")) { + } else if (is_node) { Node * current_node = current_obj->cast_to<Node>(); ERR_FAIL_COND(!current_node); @@ -1718,10 +1734,14 @@ void EditorNode::_edit_current() { p->add_shortcut(ED_SHORTCUT("property_editor/copy_resource",TTR("Copy Resource")),RESOURCE_COPY); p->add_shortcut(ED_SHORTCUT("property_editor/unref_resource",TTR("Make Built-In")),RESOURCE_UNREF); } - p->add_separator(); - p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique",TTR("Make Sub-Resources Unique")),OBJECT_UNIQUE_RESOURCES); - p->add_separator(); - p->add_icon_shortcut(gui_base->get_icon("Help","EditorIcons"),ED_SHORTCUT("property_editor/open_help",TTR("Open in Help")),OBJECT_REQUEST_HELP); + + if (is_resource || is_node) { + p->add_separator(); + p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique",TTR("Make Sub-Resources Unique")),OBJECT_UNIQUE_RESOURCES); + p->add_separator(); + p->add_icon_shortcut(gui_base->get_icon("Help","EditorIcons"),ED_SHORTCUT("property_editor/open_help",TTR("Open in Help")),OBJECT_REQUEST_HELP); + } + List<MethodInfo> methods; current_obj->get_method_list(&methods); @@ -1800,7 +1820,6 @@ void EditorNode::_run(bool p_current,const String& p_custom) { String args; - if (p_current || (editor_data.get_edited_scene_root() && p_custom==editor_data.get_edited_scene_root()->get_filename())) { Node *scene = editor_data.get_edited_scene_root(); @@ -1823,12 +1842,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) { } - bool autosave = EDITOR_DEF("run/auto_save_before_running",true); - - if (autosave) { - _menu_option(FILE_SAVE_SCENE); - } if (run_settings_dialog->get_run_mode()==RunSettingsDialog::RUN_LOCAL_SCENE) { @@ -1851,12 +1865,31 @@ void EditorNode::_run(bool p_current,const String& p_custom) { current_option=-1; //accept->get_cancel()->hide(); - accept->get_ok()->set_text(TTR("I see..")); - accept->set_text(TTR("No main scene has ever been defined.\nSelect one from \"Project Settings\" under the 'application' category.")); - accept->popup_centered_minsize(); + pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in later in \"Project Settings\" under the 'application' category.")); + pick_main_scene->popup_centered_minsize(); return; } + if (!FileAccess::exists(run_filename)) { + + current_option=-1; + //accept->get_cancel()->hide(); + pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), run_filename)); + pick_main_scene->popup_centered_minsize(); + return; + + } + + if (ResourceLoader::get_resource_type(run_filename)!="PackedScene") { + + current_option=-1; + //accept->get_cancel()->hide(); + pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), run_filename)); + pick_main_scene->popup_centered_minsize(); + return; + + } + } @@ -1882,7 +1915,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) { _save_scene_with_preview(scene->get_filename()); } } - + _menu_option(FILE_SAVE_ALL_SCENES); editor_data.save_editor_external_data(); } @@ -2103,7 +2136,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } file->set_mode(EditorFileDialog::MODE_SAVE_FILE); - bool relpaths = (scene->has_meta("__editor_relpaths__") && scene->get_meta("__editor_relpaths__").operator bool()); List<String> extensions; @@ -2129,7 +2161,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { String existing; if (extensions.size()) { String root_name(get_edited_scene()->get_name()); - existing=root_name+".tscn";//+extensions.front()->get().to_lower(); + existing=root_name+"."+extensions.front()->get().to_lower(); } file->set_current_path(existing); @@ -2139,6 +2171,19 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; + case FILE_SAVE_ALL_SCENES: { + for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { + Node *scene = editor_data.get_edited_scene_root(i); + if (scene && scene->get_filename()!="") { + // save in background if in the script editor + if (i != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT) { + _save_scene(scene->get_filename(), i); + } else { + _save_scene_with_preview(scene->get_filename()); + } + }// else: ignore new scenes + } + } break; case FILE_SAVE_BEFORE_RUN: { if (!p_confirmed) { accept->get_ok()->set_text(TTR("Yes")); @@ -2184,8 +2229,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } - bool relpaths = (scene->has_meta("__editor_relpaths__") && scene->get_meta("__editor_relpaths__").operator bool()); - file->set_mode(EditorFileDialog::MODE_SAVE_FILE); file->set_current_path(cpath); @@ -2194,8 +2237,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case FILE_SAVE_OPTIMIZED: { - Node *scene = editor_data.get_edited_scene_root(); #if 0 + Node *scene = editor_data.get_edited_scene_root(); if (!scene) { current_option=-1; @@ -2468,7 +2511,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { #endif case RESOURCE_NEW: { - create_dialog->popup_centered_ratio(); + create_dialog->popup(true); } break; case RESOURCE_LOAD: { @@ -2639,11 +2682,16 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case RUN_PLAY_NATIVE: { - _menu_option_confirm(RUN_STOP,true); - emit_signal("play_pressed"); - editor_run.run_native_notify(); - - + + bool autosave = EDITOR_DEF("run/auto_save_before_running",true); + if (autosave) { + _menu_option_confirm(FILE_SAVE_ALL_SCENES, false); + } + if (run_native->is_deploy_debug_remote_enabled()){ + _menu_option_confirm(RUN_STOP,true); + emit_signal("play_pressed"); + editor_run.run_native_notify(); + } } break; case RUN_SCENE_SETTINGS: { @@ -2756,10 +2804,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { settings_config_dialog->popup_edit_settings(); } break; - case SETTINGS_IMPORT: { - - import_settings->popup_import_settings(); - } break; case SETTINGS_OPTIMIZED_PRESETS: { //optimized_presets->popup_centered_ratio(); @@ -2770,6 +2814,30 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { file_templates->popup_centered_ratio(); } break; + case SETTINGS_PICK_MAIN_SCENE: { + + + //print_tree(); + file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + //not for now? + List<String> extensions; + ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions); + file->clear_filters(); + for(int i=0;i<extensions.size();i++) { + + file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper()); + } + + + //file->set_current_path(current_path); + Node *scene = editor_data.get_edited_scene_root(); + if (scene) { + file->set_current_path(scene->get_filename()); + }; + file->set_title(TTR("Pick a Main Scene")); + file->popup_centered_ratio(); + + } break; case SETTINGS_ABOUT: { about->popup_centered(Size2(500,130)*EDSCALE); @@ -2783,10 +2851,12 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { List<Ref<Resource> > cached; ResourceCache::get_cached_resources(&cached); - + //this should probably be done in a thread.. for(List<Ref<Resource> >::Element *E=cached.front();E;E=E->next()) { - if (!E->get()->can_reload_from_file()) + if (!E->get()->editor_can_reload_from_file()) + continue; + if (!E->get()->get_path().is_resource_file() && !E->get()->get_path().is_abs_path()) continue; if (!FileAccess::exists(E->get()->get_path())) continue; @@ -2794,6 +2864,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (mt!=E->get()->get_last_modified_time()) { E->get()->reload_from_file(); } + } @@ -3080,6 +3151,11 @@ void EditorNode::_remove_edited_scene() { new_index=1; } + + + if (editor_data.get_scene_path(old_index)!=String()) { + ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(editor_data.get_scene_path(old_index)); + } _scene_tab_changed(new_index); editor_data.remove_scene(old_index); editor_data.get_undo_redo().clear_history(); @@ -3377,7 +3453,10 @@ Dictionary EditorNode::_get_main_scene_state() { return state; } -void EditorNode::_set_main_scene_state(Dictionary p_state) { +void EditorNode::_set_main_scene_state(Dictionary p_state,Node* p_for_scene) { + + if (get_edited_scene()!=p_for_scene && p_for_scene!=NULL) + return; //not for this scene //print_line("set current 7 "); changing_scene=false; @@ -3521,7 +3600,7 @@ void EditorNode::set_current_scene(int p_idx) { }*/ //_set_main_scene_state(state); - call_deferred("_set_main_scene_state",state); //do after everything else is done setting up + call_deferred("_set_main_scene_state",state,get_edited_scene()); //do after everything else is done setting up //print_line("set current 6 "); @@ -3541,7 +3620,7 @@ void EditorNode::fix_dependencies(const String& p_for_file) { dependency_fixer->edit(p_for_file); } -Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bool p_set_inherited) { +Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bool p_set_inherited,bool p_clear_errors) { if (!is_inside_tree()) { defer_load_scene = p_scene; @@ -3560,7 +3639,9 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo } - load_errors->clear(); + if (p_clear_errors) + load_errors->clear(); + String lpath = Globals::get_singleton()->localize_path(p_scene); if (!lpath.begins_with("res://")) { @@ -3997,15 +4078,17 @@ 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()); + //CharString err_ut = p_error.utf8(); + //ERR_PRINT(!err_ut.get_data()); _load_error_notify(singleton,p_error); } void EditorNode::_load_error_notify(void* p_ud,const String& p_text) { + EditorNode*en=(EditorNode*)p_ud; - en->load_errors->set_text(en->load_errors->get_text()+p_text+"\n"); + en->load_errors->add_image(en->gui_base->get_icon("Error","EditorIcons")); + en->load_errors->add_text(p_text+"\n"); en->load_error_dialog->popup_centered_ratio(0.5); } @@ -5059,6 +5142,78 @@ void EditorNode::_file_access_close_error_notify(const String& p_str) { add_io_error("Unable to write to file '"+p_str+"', file in use, locked or lacking permissions."); } + +void EditorNode::reload_scene(const String& p_path) { + + + //first of all, reload textures as they might have changed on disk + + List<Ref<Resource> > cached; + ResourceCache::get_cached_resources(&cached); + List<Ref<Resource> > to_clear; //clear internal resources from previous scene from being used + for(List<Ref<Resource> >::Element *E=cached.front();E;E=E->next()) { + + if (E->get()->get_path().begins_with(p_path+"::")) //subresources of existing scene + to_clear.push_back(E->get()); + + if (!E->get()->cast_to<Texture>()) + continue; + if (!E->get()->get_path().is_resource_file() && !E->get()->get_path().is_abs_path()) + continue; + if (!FileAccess::exists(E->get()->get_path())) + continue; + uint64_t mt = FileAccess::get_modified_time(E->get()->get_path()); + if (mt!=E->get()->get_last_modified_time()) { + E->get()->reload_from_file(); + } + } + + //so reload reloads everything, clear subresources of previous scene + while(to_clear.front()) { + to_clear.front()->get()->set_path(""); + to_clear.pop_front(); + } + + int scene_idx=-1; + for(int i=0;i<editor_data.get_edited_scene_count();i++) { + + if (editor_data.get_scene_path(i)==p_path) { + scene_idx=i; + break; + } + } + + int current_tab = editor_data.get_edited_scene(); + + + if (scene_idx==-1) { + if (get_edited_scene()) { + //scene is not open, so at it might be instanced, just refresh, set tab to itself and it will reload + set_current_scene(current_tab); + editor_data.get_undo_redo().clear_history(); + } + return; + } + + + if (current_tab==scene_idx) { + editor_data.apply_changes_in_editors(); + _set_scene_metadata(p_path); + + } + //remove scene + _remove_scene(scene_idx); + //reload scene + load_scene(p_path); + //adjust index so tab is back a the previous position + editor_data.move_edited_scene_to_index(scene_idx); + get_undo_redo()->clear_history(); + //recover the tab + scene_tabs->set_current_tab(current_tab); + _scene_tab_changed(current_tab); +} + + void EditorNode::_bind_methods() { @@ -5502,7 +5657,10 @@ EditorNode::EditorNode() { ED_SHORTCUT("editor/fullscreen_mode",TTR("Fullscreen Mode"),KEY_MASK_SHIFT|KEY_F11); ED_SHORTCUT("editor/distraction_free_mode",TTR("Distraction Free Mode"),KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F11); - Separator *vs=NULL; + + ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD+KEY_TAB); + ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD+KEY_MASK_SHIFT+KEY_TAB); + file_menu->set_tooltip(TTR("Operations with scene files.")); p=file_menu->get_popup(); @@ -5512,6 +5670,7 @@ EditorNode::EditorNode() { p->add_separator(); p->add_shortcut(ED_SHORTCUT("editor/save_scene",TTR("Save Scene"),KEY_MASK_CMD+KEY_S),FILE_SAVE_SCENE); p->add_shortcut(ED_SHORTCUT("editor/save_scene_as",TTR("Save Scene As.."),KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S),FILE_SAVE_AS_SCENE); + p->add_shortcut(ED_SHORTCUT("editor/save_all_scenes",TTR("Save all Scenes"),KEY_MASK_ALT+KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S),FILE_SAVE_ALL_SCENES); p->add_separator(); p->add_shortcut(ED_SHORTCUT("editor/close_scene",TTR("Close Scene"),KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_W),FILE_CLOSE); p->add_separator(); @@ -5704,7 +5863,8 @@ EditorNode::EditorNode() { play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE); play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons")); play_custom_scene_button->connect("pressed", this,"_menu_option",make_binds(RUN_PLAY_CUSTOM_SCENE)); - play_custom_scene_button->set_tooltip(TTR("Play custom scene")+" ("+keycode_get_string(KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F5)+")."); + play_custom_scene_button->set_tooltip(TTR("Play custom scene")); + play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene",TTR("Play Custom Scene"),KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F5)); debug_button = memnew( MenuButton ); debug_button->set_flat(true); @@ -6152,8 +6312,6 @@ EditorNode::EditorNode() { open_recent_confirmation->connect("confirmed",this,"_open_recent_scene_confirm"); - import_settings= memnew(ImportSettingsDialog(this)); - gui_base->add_child(import_settings); run_settings_dialog = memnew( RunSettingsDialog ); gui_base->add_child( run_settings_dialog ); @@ -6417,13 +6575,14 @@ EditorNode::EditorNode() { set_process_unhandled_input(true); _playing_edited=false; - load_errors = memnew( TextEdit ); - load_errors->set_readonly(true); +// Panel *errors = memnew( Panel ); + load_errors = memnew( RichTextLabel ); +// load_errors->set_readonly(true); load_error_dialog = memnew( AcceptDialog ); load_error_dialog->add_child(load_errors); load_error_dialog->set_title(TTR("Load Errors")); load_error_dialog->set_child_rect(load_errors); - add_child(load_error_dialog); + gui_base->add_child(load_error_dialog); //EditorImport::add_importer( Ref<EditorImporterCollada>( memnew(EditorImporterCollada ))); @@ -6448,7 +6607,10 @@ EditorNode::EditorNode() { Node::set_human_readable_collision_renaming(true); - + pick_main_scene = memnew( ConfirmationDialog ); + gui_base->add_child(pick_main_scene); + pick_main_scene->get_ok()->set_text("Select"); + pick_main_scene->connect("confirmed",this,"_menu_option",varray(SETTINGS_PICK_MAIN_SCENE)); // Ref<ImageTexture> it = gui_base->get_icon("logo","Icons"); // OS::get_singleton()->set_icon( it->get_data() ); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index bea973a357..d18de1c531 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -74,7 +74,6 @@ #include "tools/editor/editor_sub_scene.h" #include "editor_import_export.h" #include "editor_reimport_dialog.h" -#include "import_settings.h" #include "tools/editor/editor_plugin.h" #include "tools/editor/editor_name_dialog.h" @@ -125,6 +124,7 @@ private: FILE_OPEN_SCENE, FILE_SAVE_SCENE, FILE_SAVE_AS_SCENE, + FILE_SAVE_ALL_SCENES, FILE_SAVE_BEFORE_RUN, FILE_SAVE_AND_RUN, FILE_IMPORT_SUBSCENE, @@ -177,7 +177,6 @@ private: RUN_RELOAD_SCRIPTS, SETTINGS_UPDATE_ALWAYS, SETTINGS_UPDATE_CHANGES, - SETTINGS_IMPORT, SETTINGS_EXPORT_PREFERENCES, SETTINGS_PREFERENCES, SETTINGS_OPTIMIZED_PRESETS, @@ -185,6 +184,7 @@ private: SETTINGS_LAYOUT_DELETE, SETTINGS_LAYOUT_DEFAULT, SETTINGS_LOAD_EXPORT_TEMPLATES, + SETTINGS_PICK_MAIN_SCENE, SETTINGS_HELP, SETTINGS_ABOUT, SOURCES_REIMPORT, @@ -261,7 +261,7 @@ private: TextureProgress *audio_vu; //MenuButton *fileserver_menu; - TextEdit *load_errors; + RichTextLabel *load_errors; AcceptDialog *load_error_dialog; //Control *scene_root_base; @@ -287,6 +287,7 @@ private: ConfirmationDialog *confirmation; ConfirmationDialog *import_confirmation; ConfirmationDialog *open_recent_confirmation; + ConfirmationDialog *pick_main_scene; AcceptDialog *accept; AcceptDialog *about; AcceptDialog *warning; @@ -336,7 +337,6 @@ private: Vector<EditorPlugin*> editor_table; EditorReImportDialog *reimport_dialog; - ImportSettingsDialog *import_settings; ProgressDialog *progress_dialog; BackgroundProgress *progress_hb; @@ -439,7 +439,7 @@ private: void _node_renamed(); void _editor_select(int p_which); - void _set_scene_metadata(const String &p_file); + void _set_scene_metadata(const String &p_file, int p_idx=-1); void _get_scene_metadata(const String& p_file); void _update_title(); void _update_scene_tabs(); @@ -449,7 +449,7 @@ private: void _rebuild_import_menu(); - void _save_scene(String p_file); + void _save_scene(String p_file, int idx = -1); void _instance_request(const String& p_path); @@ -553,7 +553,7 @@ private: void _scene_tab_script_edited(int p_tab); Dictionary _get_main_scene_state(); - void _set_main_scene_state(Dictionary p_state); + void _set_main_scene_state(Dictionary p_state,Node* p_for_scene); int _get_current_main_editor(); @@ -652,7 +652,7 @@ public: void fix_dependencies(const String& p_for_file); void clear_scene() { _cleanup_scene(); } - Error load_scene(const String& p_scene, bool p_ignore_broken_deps=false, bool p_set_inherited=false); + Error load_scene(const String& p_scene, bool p_ignore_broken_deps=false, bool p_set_inherited=false, bool p_clear_errors=true); Error load_resource(const String& p_scene); bool is_scene_open(const String& p_path); @@ -714,6 +714,8 @@ public: void update_keying(); + void reload_scene(const String& p_path); + bool is_exiting() const { return exiting; } ToolButton *get_pause_button() { return pause_button; } @@ -758,7 +760,7 @@ public: plugins_list = p_plugins_list; } - Vector<EditorPlugin*> get_plugins_list() { + Vector<EditorPlugin*>& get_plugins_list() { return plugins_list; } diff --git a/tools/editor/editor_path.cpp b/tools/editor/editor_path.cpp index 4cf98e832c..6b804b6a24 100644 --- a/tools/editor/editor_path.cpp +++ b/tools/editor/editor_path.cpp @@ -38,7 +38,6 @@ void EditorPath::_notification(int p_what) { RID ci=get_canvas_item(); Ref<Font> label_font = get_font("font","Label"); - Color label_color = get_color("font_color","Label"); Size2i size = get_size(); Ref<Texture> sn = get_icon("SmallNext","EditorIcons"); diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp index 138e532ce8..01e6b613c0 100644 --- a/tools/editor/editor_plugin.cpp +++ b/tools/editor/editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_plugin.h" +#include "scene/3d/camera.h" #include "plugins/canvas_item_editor_plugin.h" #include "plugins/spatial_editor_plugin.h" #include "tools/editor/editor_node.h" diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index 8975c0ec35..a02fe2a531 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -33,6 +33,7 @@ #include "io/resource_saver.h" #include "globals.h" #include "editor_scale.h" +#include "message_queue.h" Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String& p_path) { @@ -66,25 +67,27 @@ void EditorResourcePreview::_preview_ready(const String& p_str,const Ref<Texture String path = p_str; uint32_t hash=0; + uint64_t modified_time=0; if (p_str.begins_with("ID:")) { hash=p_str.get_slicec(':',2).to_int(); path="ID:"+p_str.get_slicec(':',1); + } else { + modified_time = FileAccess::get_modified_time(path); } Item item; item.order=order++; item.preview=p_texture; item.last_hash=hash; + item.modified_time=modified_time; cache[path]=item; - Object *recv = ObjectDB::get_instance(id); - if (recv) { - recv->call_deferred(p_func,path,p_texture,p_ud); - } - preview_mutex->unlock(); + + MessageQueue::get_singleton()->push_call(id,p_func,path,p_texture,p_ud); + } Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem& p_item,const String& cache_base) { @@ -103,6 +106,7 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem& p_item,co Ref<Texture> generated; for(int i=0;i<preview_generators.size();i++) { + if (!preview_generators[i]->handles(type)) continue; if (p_item.resource.is_valid()) { @@ -153,99 +157,107 @@ void EditorResourcePreview::_thread() { QueueItem item = queue.front()->get(); queue.pop_front(); - preview_mutex->unlock(); - - Ref<Texture> texture; - - //print_line("pop from queue "+item.path); - - int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size"); - thumbnail_size*=EDSCALE; if (cache.has(item.path)) { //already has it because someone loaded it, just let it know it's ready if (item.resource.is_valid()) { item.path+=":"+itos(cache[item.path].last_hash); //keep last hash (see description of what this is in condition below) } - call_deferred("_preview_ready",item.path,cache[item.path].preview,item.id,item.function,item.userdata); - - } else if (item.resource.is_valid()){ - texture=_generate_preview(item,String()); - //adding hash to the end of path (should be ID:<objid>:<hash>) because of 5 argument limit to call_deferred - call_deferred("_preview_ready",item.path+":"+itos(item.resource->hash_edited_version()),texture,item.id,item.function,item.userdata); + _preview_ready(item.path,cache[item.path].preview,item.id,item.function,item.userdata); + preview_mutex->unlock(); } else { + preview_mutex->unlock(); - String temp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp"); - String cache_base = Globals::get_singleton()->globalize_path(item.path).md5_text(); - cache_base = temp_path.plus_file("resthumb-"+cache_base); + Ref<Texture> texture; - //does not have it, try to load a cached thumbnail + //print_line("pop from queue "+item.path); - String file = cache_base+".txt"; - //print_line("cachetxt at "+file); - FileAccess *f=FileAccess::open(file,FileAccess::READ); - if (!f) { + int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size"); + thumbnail_size*=EDSCALE; - //print_line("generate because not cached"); - //generate - texture=_generate_preview(item,cache_base); + if (item.resource.is_valid()){ + + texture=_generate_preview(item,String()); + //adding hash to the end of path (should be ID:<objid>:<hash>) because of 5 argument limit to call_deferred + _preview_ready(item.path+":"+itos(item.resource->hash_edited_version()),texture,item.id,item.function,item.userdata); + } else { - uint64_t modtime = FileAccess::get_modified_time(item.path); - int tsize = f->get_line().to_int64(); - uint64_t last_modtime = f->get_line().to_int64(); - bool cache_valid = true; + String temp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp"); + String cache_base = Globals::get_singleton()->globalize_path(item.path).md5_text(); + cache_base = temp_path.plus_file("resthumb-"+cache_base); - if (tsize!=thumbnail_size) { - cache_valid=false; - memdelete(f); - } else if (last_modtime!=modtime) { + //does not have it, try to load a cached thumbnail - String last_md5 = f->get_line(); - String md5 = FileAccess::get_md5(item.path); - memdelete(f); + String file = cache_base+".txt"; + //print_line("cachetxt at "+file); + FileAccess *f=FileAccess::open(file,FileAccess::READ); + if (!f) { - if (last_md5!=md5) { + //print_line("generate because not cached"); + //generate + texture=_generate_preview(item,cache_base); + } else { + + uint64_t modtime = FileAccess::get_modified_time(item.path); + int tsize = f->get_line().to_int64(); + uint64_t last_modtime = f->get_line().to_int64(); + + bool cache_valid = true; + + if (tsize!=thumbnail_size) { cache_valid=false; - } else { - //update modified time + memdelete(f); + } else if (last_modtime!=modtime) { + + String last_md5 = f->get_line(); + String md5 = FileAccess::get_md5(item.path); + memdelete(f); + + if (last_md5!=md5) { - f=FileAccess::open(file,FileAccess::WRITE); - f->store_line(itos(modtime)); - f->store_line(md5); + cache_valid=false; + } else { + //update modified time + + f=FileAccess::open(file,FileAccess::WRITE); + f->store_line(itos(modtime)); + f->store_line(md5); + memdelete(f); + } + } else { memdelete(f); } - } else { - memdelete(f); - } - if (cache_valid) { + if (cache_valid) { - texture = ResourceLoader::load(cache_base+".png","ImageTexture",true); - if (!texture.is_valid()) { - //well fuck - cache_valid=false; + texture = ResourceLoader::load(cache_base+".png","ImageTexture",true); + if (!texture.is_valid()) { + //well fuck + cache_valid=false; + } } - } - if (!cache_valid) { + if (!cache_valid) { - texture=_generate_preview(item,cache_base); - } + texture=_generate_preview(item,cache_base); + } - } + } - //print_line("notify of preview ready"); - call_deferred("_preview_ready",item.path,texture,item.id,item.function,item.userdata); + //print_line("notify of preview ready"); + _preview_ready(item.path,texture,item.id,item.function,item.userdata); + } } + } else { preview_mutex->unlock(); } @@ -263,6 +275,8 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource>& p preview_mutex->lock(); String path_id = "ID:"+itos(p_res->get_instance_ID()); + + if (cache.has(path_id) && cache[path_id].last_hash==p_res->hash_edited_version()) { cache[path_id].order=order++; @@ -272,6 +286,8 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource>& p } + cache.erase(path_id); //erase if exists, since it will be regen + //print_line("send to thread "+p_path); QueueItem item; item.function=p_receiver_func; @@ -322,6 +338,34 @@ EditorResourcePreview* EditorResourcePreview::get_singleton() { void EditorResourcePreview::_bind_methods() { ObjectTypeDB::bind_method("_preview_ready",&EditorResourcePreview::_preview_ready); + ObjectTypeDB::bind_method(_MD("check_for_invalidation","path"),&EditorResourcePreview::check_for_invalidation); + + + ADD_SIGNAL(MethodInfo("preview_invalidated",PropertyInfo(Variant::STRING,"path"))); +} + +void EditorResourcePreview::check_for_invalidation(const String& p_path) { + + preview_mutex->lock(); + + bool call_invalidated=false; + if (cache.has(p_path)) { + + uint64_t modified_time = FileAccess::get_modified_time(p_path); + if (modified_time!=cache[p_path].modified_time) { + cache.erase(p_path); + call_invalidated=true; + } + } + + preview_mutex->unlock(); + + if (call_invalidated) {//do outside mutex + call_deferred("emit_signal","preview_invalidated",p_path); + } + + + } EditorResourcePreview::EditorResourcePreview() { diff --git a/tools/editor/editor_resource_preview.h b/tools/editor/editor_resource_preview.h index 63dc5c3dd3..51a00965eb 100644 --- a/tools/editor/editor_resource_preview.h +++ b/tools/editor/editor_resource_preview.h @@ -93,6 +93,7 @@ class EditorResourcePreview : public Node { Ref<Texture> preview; int order; uint32_t last_hash; + uint64_t modified_time; }; int order; @@ -106,6 +107,8 @@ class EditorResourcePreview : public Node { void _thread(); Vector<Ref<EditorResourcePreviewGenerator> > preview_generators; + + protected: static void _bind_methods(); @@ -118,6 +121,7 @@ public: void queue_edited_resource_preview(const Ref<Resource>& p_path, Object* p_receiver, const StringName& p_receiver_func, const Variant& p_userdata); void add_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator); + void check_for_invalidation(const String& p_path); EditorResourcePreview(); ~EditorResourcePreview(); diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp index 234dd03087..edbcc71284 100644 --- a/tools/editor/editor_run_native.cpp +++ b/tools/editor/editor_run_native.cpp @@ -101,10 +101,8 @@ void EditorRunNative::_run_native(int p_idx,const String& p_platform) { Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(p_platform); ERR_FAIL_COND(eep.is_null()); - if (deploy_debug_remote) { - emit_signal("native_run"); + emit_signal("native_run"); - } int flags=0; if (deploy_debug_remote) flags|=EditorExportPlatform::EXPORT_REMOTE_DEBUG; diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 457aecba4a..c150e62754 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -104,12 +104,17 @@ bool EditorSettings::_get(const StringName& p_name,Variant &r_ret) const { for (const Map<String,Ref<ShortCut> >::Element *E=shortcuts.front();E;E=E->next()) { Ref<ShortCut> sc=E->get(); - if (!sc->has_meta("original")) - continue; //this came from settings but is not any longer used - InputEvent original = sc->get_meta("original"); - if (sc->is_shortcut(original) || (original.type==InputEvent::NONE && sc->get_shortcut().type==InputEvent::NONE)) - continue; //not changed from default, don't save + if (optimize_save) { + if (!sc->has_meta("original")) { + continue; //this came from settings but is not any longer used + } + + InputEvent original = sc->get_meta("original"); + if (sc->is_shortcut(original) || (original.type==InputEvent::NONE && sc->get_shortcut().type==InputEvent::NONE)) + continue; //not changed from default, don't save + } + arr.push_back(E->key()); arr.push_back(sc->get_shortcut()); } @@ -161,7 +166,7 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { for(Set<_EVCSort>::Element *E=vclist.front();E;E=E->next()) { int pinfo = 0; - if (E->get().save) { + if (E->get().save || !optimize_save) { pinfo|=PROPERTY_USAGE_STORAGE; } @@ -423,7 +428,7 @@ void EditorSettings::setup_network() { if (ip=="127.0.0.1") continue; - if (lip!="") + if (lip=="") lip=ip; if (ip==current) lip=current; //so it saves @@ -549,6 +554,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("text_editor/create_signal_callbacks",true); set("text_editor/autosave_interval_secs",0); + set("text_editor/block_caret", false); set("text_editor/caret_blink", false); set("text_editor/caret_blink_speed", 0.65); hints["text_editor/caret_blink_speed"]=PropertyInfo(Variant::REAL,"text_editor/caret_blink_speed",PROPERTY_HINT_RANGE,"0.1, 10, 0.1"); @@ -677,7 +683,10 @@ void EditorSettings::_load_default_text_editor_theme() { set("text_editor/completion_background_color", Color::html("2C2A32")); set("text_editor/completion_selected_color", Color::html("434244")); set("text_editor/completion_existing_color", Color::html("21dfdfdf")); + set("text_editor/completion_scroll_color", Color::html("ffffff")); + set("text_editor/completion_font_color", Color::html("aaaaaa")); set("text_editor/caret_color",Color::html("aaaaaa")); + set("text_editor/caret_background_color", Color::html("000000")); set("text_editor/line_number_color",Color::html("66aaaaaa")); set("text_editor/text_color",Color::html("aaaaaa")); set("text_editor/text_selected_color",Color::html("000000")); @@ -912,7 +921,10 @@ bool EditorSettings::_save_text_editor_theme(String p_file) { cf->set_value(theme_section, "completion_background_color", ((Color)get("text_editor/completion_background_color")).to_html()); cf->set_value(theme_section, "completion_selected_color", ((Color)get("text_editor/completion_selected_color")).to_html()); cf->set_value(theme_section, "completion_existing_color", ((Color)get("text_editor/completion_existing_color")).to_html()); + cf->set_value(theme_section, "completion_scroll_color", ((Color)get("text_editor/completion_scroll_color")).to_html()); + cf->set_value(theme_section, "completion_font_color", ((Color)get("text_editor/completion_font_color")).to_html()); cf->set_value(theme_section, "caret_color", ((Color)get("text_editor/caret_color")).to_html()); + cf->set_value(theme_section, "caret_background_color", ((Color)get("text_editor/caret_background_color")).to_html()); cf->set_value(theme_section, "line_number_color", ((Color)get("text_editor/line_number_color")).to_html()); cf->set_value(theme_section, "text_color", ((Color)get("text_editor/text_color")).to_html()); cf->set_value(theme_section, "text_selected_color", ((Color)get("text_editor/text_selected_color")).to_html()); @@ -976,6 +988,10 @@ void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) { } } +void EditorSettings::set_optimize_save(bool p_optimize) { + + optimize_save=p_optimize; +} void EditorSettings::_bind_methods() { @@ -998,6 +1014,7 @@ EditorSettings::EditorSettings() { //singleton=this; last_order=0; + optimize_save=true; save_changed_setting=true; EditorTranslationList *etl=_editor_translations; diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h index d975a7ef86..937956a366 100644 --- a/tools/editor/editor_settings.h +++ b/tools/editor/editor_settings.h @@ -88,6 +88,7 @@ private: bool save_changed_setting; + bool optimize_save; //do not save stuff that came from config but was not set from engine void _load_defaults(Ref<ConfigFile> p_extra_config = NULL); void _load_default_text_editor_theme(); @@ -155,6 +156,8 @@ public: Ref<ShortCut> get_shortcut(const String&p_name) const; void get_shortcut_list(List<String> *r_shortcuts); + void set_optimize_save(bool p_optimize); + EditorSettings(); ~EditorSettings(); diff --git a/tools/editor/groups_editor.cpp b/tools/editor/groups_editor.cpp index 898e1e115e..5b7bc1da78 100644 --- a/tools/editor/groups_editor.cpp +++ b/tools/editor/groups_editor.cpp @@ -31,7 +31,7 @@ #include "scene/gui/box_container.h" #include "scene/gui/label.h" #include "editor_node.h" - +#include "scene/resources/packed_scene.h" void GroupsEditor::_add_group(const String& p_group) { if (!node) @@ -107,9 +107,35 @@ void GroupsEditor::update_tree() { if (!gi.persistent) continue; + Node *n = node; + bool can_be_deleted=true; + + while(n) { + + Ref<SceneState> ss = (n==EditorNode::get_singleton()->get_edited_scene()) ? n->get_scene_inherited_state() : n->get_scene_instance_state(); + + if (ss.is_valid()) { + + int path = ss->find_node_by_path(n->get_path_to(node)); + if (path!=-1) { + if (ss->is_node_in_group(path,gi.name)) { + can_be_deleted=false; + } + } + } + + n=n->get_owner(); + } + + TreeItem *item=tree->create_item(root); item->set_text(0, gi.name); - item->add_button(0, get_icon("Remove", "EditorIcons"), 0); + if (can_be_deleted) { + item->add_button(0, get_icon("Remove", "EditorIcons"), 0); + } else { + item->set_selectable(0,false); + } + } } diff --git a/tools/editor/icons/2x/icon_gizmo_directional_light.png b/tools/editor/icons/2x/icon_gizmo_directional_light.png Binary files differindex 5f812845df..0d02788040 100644 --- a/tools/editor/icons/2x/icon_gizmo_directional_light.png +++ b/tools/editor/icons/2x/icon_gizmo_directional_light.png diff --git a/tools/editor/icons/2x/icon_gizmo_light.png b/tools/editor/icons/2x/icon_gizmo_light.png Binary files differindex 3b1b15f4b6..2ba9689107 100644 --- a/tools/editor/icons/2x/icon_gizmo_light.png +++ b/tools/editor/icons/2x/icon_gizmo_light.png diff --git a/tools/editor/icons/2x/icon_gizmo_listener.png b/tools/editor/icons/2x/icon_gizmo_listener.png Binary files differindex 9fbf16c015..bc2908824d 100644 --- a/tools/editor/icons/2x/icon_gizmo_listener.png +++ b/tools/editor/icons/2x/icon_gizmo_listener.png diff --git a/tools/editor/icons/2x/icon_gizmo_spatial_sample_player.png b/tools/editor/icons/2x/icon_gizmo_spatial_sample_player.png Binary files differindex f67beb14c5..78a88c55c1 100644 --- a/tools/editor/icons/2x/icon_gizmo_spatial_sample_player.png +++ b/tools/editor/icons/2x/icon_gizmo_spatial_sample_player.png diff --git a/tools/editor/icons/2x/icon_gizmo_spatial_stream_player.png b/tools/editor/icons/2x/icon_gizmo_spatial_stream_player.png Binary files differindex feed191fc1..631f03e874 100644 --- a/tools/editor/icons/2x/icon_gizmo_spatial_stream_player.png +++ b/tools/editor/icons/2x/icon_gizmo_spatial_stream_player.png diff --git a/tools/editor/icons/2x/icon_zoom_less.png b/tools/editor/icons/2x/icon_zoom_less.png Binary files differnew file mode 100644 index 0000000000..d483db55ce --- /dev/null +++ b/tools/editor/icons/2x/icon_zoom_less.png diff --git a/tools/editor/icons/2x/icon_zoom_more.png b/tools/editor/icons/2x/icon_zoom_more.png Binary files differnew file mode 100644 index 0000000000..8f9ef77849 --- /dev/null +++ b/tools/editor/icons/2x/icon_zoom_more.png diff --git a/tools/editor/icons/2x/icon_zoom_reset.png b/tools/editor/icons/2x/icon_zoom_reset.png Binary files differnew file mode 100644 index 0000000000..092215b3e2 --- /dev/null +++ b/tools/editor/icons/2x/icon_zoom_reset.png diff --git a/tools/editor/icons/icon_gizmo_directional_light.png b/tools/editor/icons/icon_gizmo_directional_light.png Binary files differindex a716930687..bdeb120b43 100644 --- a/tools/editor/icons/icon_gizmo_directional_light.png +++ b/tools/editor/icons/icon_gizmo_directional_light.png diff --git a/tools/editor/icons/icon_gizmo_light.png b/tools/editor/icons/icon_gizmo_light.png Binary files differindex 396ae8615d..be9903f8c2 100644 --- a/tools/editor/icons/icon_gizmo_light.png +++ b/tools/editor/icons/icon_gizmo_light.png diff --git a/tools/editor/icons/icon_gizmo_listener.png b/tools/editor/icons/icon_gizmo_listener.png Binary files differindex 218736e491..47e978be61 100644 --- a/tools/editor/icons/icon_gizmo_listener.png +++ b/tools/editor/icons/icon_gizmo_listener.png diff --git a/tools/editor/icons/icon_gizmo_spatial_sample_player.png b/tools/editor/icons/icon_gizmo_spatial_sample_player.png Binary files differindex 71e4f13f1c..0119dbc433 100644 --- a/tools/editor/icons/icon_gizmo_spatial_sample_player.png +++ b/tools/editor/icons/icon_gizmo_spatial_sample_player.png diff --git a/tools/editor/icons/icon_gizmo_spatial_stream_player.png b/tools/editor/icons/icon_gizmo_spatial_stream_player.png Binary files differindex 04144aec26..6a4f85d550 100644 --- a/tools/editor/icons/icon_gizmo_spatial_stream_player.png +++ b/tools/editor/icons/icon_gizmo_spatial_stream_player.png diff --git a/tools/editor/icons/icon_loop_interpolation.png b/tools/editor/icons/icon_loop_interpolation.png Binary files differdeleted file mode 100644 index 488b33316e..0000000000 --- a/tools/editor/icons/icon_loop_interpolation.png +++ /dev/null diff --git a/tools/editor/icons/icon_zoom_less.png b/tools/editor/icons/icon_zoom_less.png Binary files differnew file mode 100644 index 0000000000..fd8ef9075e --- /dev/null +++ b/tools/editor/icons/icon_zoom_less.png diff --git a/tools/editor/icons/icon_zoom_more.png b/tools/editor/icons/icon_zoom_more.png Binary files differnew file mode 100644 index 0000000000..8e818db1ee --- /dev/null +++ b/tools/editor/icons/icon_zoom_more.png diff --git a/tools/editor/icons/icon_zoom_reset.png b/tools/editor/icons/icon_zoom_reset.png Binary files differnew file mode 100644 index 0000000000..fa8a9d197e --- /dev/null +++ b/tools/editor/icons/icon_zoom_reset.png diff --git a/tools/editor/icons/source/icon_gizmo_directional_light.svg b/tools/editor/icons/source/icon_gizmo_directional_light.svg index 0682c270ac..65202877a0 100644 --- a/tools/editor/icons/source/icon_gizmo_directional_light.svg +++ b/tools/editor/icons/source/icon_gizmo_directional_light.svg @@ -9,15 +9,15 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="32" - height="32" - viewBox="0 0 32 32" + width="128" + height="128" + viewBox="0 0 128 128" id="svg2" version="1.1" inkscape:version="0.91 r13725" - inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_dependency_changed_hl.png" - inkscape:export-xdpi="45" - inkscape:export-ydpi="45" + inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_gizmo_directional_light.png" + inkscape:export-xdpi="360" + inkscape:export-ydpi="360" sodipodi:docname="icon_gizmo_directional_light.svg"> <defs id="defs4" /> @@ -28,9 +28,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="11.313708" - inkscape:cx="13.90442" - inkscape:cy="22.349302" + inkscape:zoom="4" + inkscape:cx="69.526732" + inkscape:cy="53.07939" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -68,106 +68,65 @@ inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" - transform="translate(0,-1020.3622)"> + transform="translate(0,-924.3622)"> <circle style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="path4156" - cx="16" - cy="1036.3622" - r="7.0000172" /> - <rect + cx="64" + cy="988.36218" + r="24.000017" /> + <path style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + d="m 64,4 a 8.0000172,8.0000172 0 0 0 -8,8 l 0,12 a 7.9999828,7.9999828 0 0 0 8,8 7.9999828,7.9999828 0 0 0 8,-8 L 72,12 A 8.0000172,8.0000172 0 0 0 64,4 Z" + transform="translate(0,924.3622)" id="rect4169" - width="4" - height="5.0000172" - x="14" - y="1021.3622" - rx="0" - ry="0" - inkscape:transform-center-y="-12.500009" /> - <rect - inkscape:transform-center-y="-8.8388501" - ry="0" - rx="0" - y="706.505" - x="742.13245" - height="5.0000172" - width="4" - id="rect4171" + inkscape:connector-curvature="0" + inkscape:transform-center-y="-46" /> + <path + inkscape:connector-curvature="0" + id="path4148" + d="m 124,988.3622 a 8.0000172,8.0000172 0 0 0 -8,-8 l -12,0 a 7.9999828,7.9999828 0 0 0 -8,8 7.9999828,7.9999828 0 0 0 8,8 l 12,0 a 8.0000172,8.0000172 0 0 0 8,-8 z" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,0,0)" - inkscape:transform-center-x="-8.8388459" /> - <rect - inkscape:transform-center-x="-12.500018" - transform="matrix(0,1,-1,0,0,0)" + inkscape:transform-center-x="-46" /> + <path style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="rect4173" - width="4" - height="5.0000172" - x="1034.3622" - y="-31.000027" - rx="0" - ry="0" - inkscape:transform-center-y="-1.754751e-05" /> - <rect - inkscape:transform-center-y="8.8388073" - ry="0" - rx="0" - y="-759.13245" - x="719.505" - height="5.0000172" - width="4" - id="rect4175" + d="m 64,1048.3622 a 8.0000172,8.0000172 0 0 0 8,-8 l 0,-12 a 7.9999828,7.9999828 0 0 0 -8,-8 7.9999828,7.9999828 0 0 0 -8,8 l 0,12 a 8.0000172,8.0000172 0 0 0 8,8 z" + id="path4150" + inkscape:connector-curvature="0" + inkscape:transform-center-y="46" /> + <path + inkscape:connector-curvature="0" + id="path4152" + d="m 4,988.3622 a 8.0000172,8.0000172 0 0 0 8,8 l 12,0 a 7.9999828,7.9999828 0 0 0 8,-8 7.9999828,7.9999828 0 0 0 -8,-8 l -12,0 a 8.0000172,8.0000172 0 0 0 -8,8 z" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - transform="matrix(-0.70710678,0.70710678,-0.70710678,-0.70710678,0,0)" - inkscape:transform-center-x="-8.8388458" /> - <rect - inkscape:transform-center-x="-2.6589615e-05" - transform="scale(-1,-1)" + inkscape:transform-center-x="46" /> + <path + inkscape:transform-center-y="-32.526909" + inkscape:connector-curvature="0" + id="path4154" + d="m 106.42641,945.93579 a 8.0000172,8.0000172 0 0 0 -11.313712,0 l -8.485281,8.48528 a 7.9999828,7.9999828 0 0 0 0,11.31371 7.9999828,7.9999828 0 0 0 11.313708,0 l 8.485285,-8.48528 a 8.0000172,8.0000172 0 0 0 0,-11.31371 z" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="rect4177" - width="4" - height="5.0000172" - x="-18.000027" - y="-1051.3622" - rx="0" - ry="0" - inkscape:transform-center-y="12.499974" /> - <rect - inkscape:transform-center-y="8.8388074" - ry="0" - rx="0" - y="-736.505" - x="-746.13245" - height="5.0000172" - width="4" - id="rect4179" + inkscape:transform-center-x="-32.526906" /> + <path + inkscape:transform-center-x="-32.526906" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - transform="matrix(-0.70710678,-0.70710678,0.70710678,-0.70710678,0,0)" - inkscape:transform-center-x="8.8388116" /> - <rect - inkscape:transform-center-x="12.499964" - transform="matrix(0,-1,1,0,0,0)" + d="m 106.42641,1030.7886 a 8.0000172,8.0000172 0 0 0 0,-11.3137 l -8.485285,-8.4853 a 7.9999828,7.9999828 0 0 0 -11.313708,0 7.9999828,7.9999828 0 0 0 0,11.3137 l 8.485281,8.4853 a 8.0000172,8.0000172 0 0 0 11.313712,0 z" + id="path4157" + inkscape:connector-curvature="0" + inkscape:transform-center-y="32.526894" /> + <path + inkscape:transform-center-y="32.526893" + inkscape:connector-curvature="0" + id="path4159" + d="m 21.573593,1030.7886 a 8.0000172,8.0000172 0 0 0 11.313709,0 l 8.485281,-8.4853 a 7.9999828,7.9999828 0 0 0 0,-11.3137 7.9999828,7.9999828 0 0 0 -11.313708,0 l -8.485282,8.4853 a 8.0000172,8.0000172 0 0 0 0,11.3137 z" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="rect4181" - width="4" - height="5.0000172" - x="-1038.3622" - y="1.0000273" - rx="0" - ry="0" - inkscape:transform-center-y="-1.7409218e-05" /> - <rect - inkscape:transform-center-y="-8.83885" - ry="0" - rx="0" - y="729.13245" - x="-723.505" - height="5.0000172" - width="4" - id="rect4183" + inkscape:transform-center-x="32.526905" /> + <path + inkscape:transform-center-x="32.526905" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,0,0)" - inkscape:transform-center-x="8.8388113" /> + d="m 21.573593,945.93579 a 8.0000172,8.0000172 0 0 0 0,11.31371 l 8.485282,8.48528 a 7.9999828,7.9999828 0 0 0 11.313708,0 7.9999828,7.9999828 0 0 0 0,-11.31371 l -8.485281,-8.48528 a 8.0000172,8.0000172 0 0 0 -11.313709,0 z" + id="path4161" + inkscape:connector-curvature="0" + inkscape:transform-center-y="-32.526908" /> </g> </svg> diff --git a/tools/editor/icons/source/icon_gizmo_light.svg b/tools/editor/icons/source/icon_gizmo_light.svg index c9ce60273a..c42d6e1f76 100644 --- a/tools/editor/icons/source/icon_gizmo_light.svg +++ b/tools/editor/icons/source/icon_gizmo_light.svg @@ -9,9 +9,9 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="32" - height="32" - viewBox="0 0 32 32" + width="128" + height="128" + viewBox="0 0 128 128" id="svg2" version="1.1" inkscape:version="0.91 r13725" @@ -28,9 +28,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="15.999999" - inkscape:cx="18.311796" - inkscape:cy="18.635805" + inkscape:zoom="3.9999998" + inkscape:cx="47.738891" + inkscape:cy="58.814006" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -68,23 +68,23 @@ inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" - transform="translate(0,-1020.3622)"> + transform="translate(0,-924.3622)"> <path style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - d="M 16 1 A 10.000017 10.000017 0 0 0 6 11 A 10.000017 10.000017 0 0 0 16 21 A 10.000017 10.000017 0 0 0 26 11 A 10.000017 10.000017 0 0 0 16 1 z M 16 4 A 7 7 0 0 1 23 11 A 7 7 0 0 1 16 18 A 7 7 0 0 1 9 11 A 7 7 0 0 1 16 4 z " - transform="translate(0,1020.3622)" - id="path4162" /> + d="m 64,930.3622 a 40.000068,40.000068 0 0 0 -40,40 40.000068,40.000068 0 0 0 40,40 40.000068,40.000068 0 0 0 40,-40 40.000068,40.000068 0 0 0 -40,-40 z m 0,12 a 28,28 0 0 1 28,28 28,28 0 0 1 -28,28 28,28 0 0 1 -28,-28 28,28 0 0 1 28,-28 z" + id="path4162" + inkscape:connector-curvature="0" /> <path style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - d="M 12 19 L 12 24 A 2 2 0 0 0 14 26 L 18 26 A 2 2 0 0 0 20 24 L 20 19 L 12 19 z " - transform="translate(0,1020.3622)" - id="rect4164" /> + d="m 48,1002.3622 0,20 a 8,8 0 0 0 8,8 l 16,0 a 8,8 0 0 0 8,-8 l 0,-20 -32,0 z" + id="rect4164" + inkscape:connector-curvature="0" /> <rect style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="rect4168" - width="4" - height="2.0000174" - x="14" - y="1048.3622" /> + width="16" + height="8.0000696" + x="56" + y="1038.3622" /> </g> </svg> diff --git a/tools/editor/icons/source/icon_gizmo_listener.svg b/tools/editor/icons/source/icon_gizmo_listener.svg index a53b08af44..3667cbc69b 100644 --- a/tools/editor/icons/source/icon_gizmo_listener.svg +++ b/tools/editor/icons/source/icon_gizmo_listener.svg @@ -9,9 +9,9 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="32" - height="32" - viewBox="0 0 32 32" + width="128" + height="128" + viewBox="0 0 128 128" id="svg2" version="1.1" inkscape:version="0.91 r13725" @@ -28,9 +28,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="15.999999" - inkscape:cx="4.4071843" - inkscape:cy="17.118049" + inkscape:zoom="3.9999998" + inkscape:cx="53.348444" + inkscape:cy="75.110194" inkscape:document-units="px" inkscape:current-layer="g4175" showgrid="true" @@ -60,7 +60,7 @@ <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title /> + <dc:title></dc:title> </cc:Work> </rdf:RDF> </metadata> @@ -68,33 +68,33 @@ inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" - transform="translate(0,-1020.3622)"> + transform="translate(0,-924.3622)"> <g id="g4175" transform="matrix(2,0,0,2,-16,-1040.3622)"> <path inkscape:connector-curvature="0" id="path4274" - d="m 21.928203,1032.3622 -1.738281,1.0039 a 6,6 0 0 1 0.810547,2.9961 6,6 0 0 1 -0.808594,2.998 l 1.736328,1.002 a 8,8 0 0 0 0,-8 z" + d="m 63.712867,990.36221 -6.953133,4.0152 a 24.000031,23.999015 0 0 1 3.242193,11.98399 24.000031,23.999015 0 0 1 -3.234381,11.9917 l 6.945321,4.0076 a 32.000041,31.998687 0 0 0 0,-31.99849 z" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> <rect - y="1043.3622" - x="11" - height="2" - width="1" + y="1034.3602" + x="19.999998" + height="7.9996719" + width="4.0000052" id="rect4147" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> <path id="path4149" - d="m 14,1031.3622 a 5,5 0 0 0 -5,5 l 2,0 a 3,3 0 0 1 3,-3 3,3 0 0 1 3,3 l 2,0 a 5,5 0 0 0 -5,-5 z" + d="m 32.000015,986.3622 a 20.000026,19.999179 0 0 0 -20.000026,19.9992 l 8.00001,0 a 12.000015,11.999507 0 0 1 12.000016,-11.99959 12.000015,11.999507 0 0 1 12.000015,11.99959 l 8.00001,0 A 20.000026,19.999179 0 0 0 32.000015,986.3622 Z" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" inkscape:connector-curvature="0" /> <path sodipodi:nodetypes="csc" inkscape:connector-curvature="0" id="path4155" - d="m 18,1036.3622 c 0,4 -3,4 -3,5 0,3 -2,3 -3,3" - style="fill:none;fill-rule:evenodd;stroke:#f7f5cf;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + d="m 48.000035,1006.3614 c 0,15.9993 -12.000015,15.9993 -12.000015,19.9993 0,11.9992 -8.00001,11.9992 -12.000016,11.9992" + style="fill:none;fill-rule:evenodd;stroke:#f7f5cf;stroke-width:7.99984121;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> </g> </g> </svg> diff --git a/tools/editor/icons/source/icon_gizmo_spatial_sample_player.svg b/tools/editor/icons/source/icon_gizmo_spatial_sample_player.svg index 68375f9487..a734095268 100644 --- a/tools/editor/icons/source/icon_gizmo_spatial_sample_player.svg +++ b/tools/editor/icons/source/icon_gizmo_spatial_sample_player.svg @@ -9,9 +9,9 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="32" - height="32" - viewBox="0 0 32 32" + width="128" + height="128" + viewBox="0 0 128 128" id="svg2" version="1.1" inkscape:version="0.91 r13725" @@ -28,9 +28,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="15.999999" - inkscape:cx="18.414591" - inkscape:cy="16.81826" + inkscape:zoom="2" + inkscape:cx="7.8244495" + inkscape:cy="69.465609" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -71,26 +71,50 @@ inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" - transform="translate(0,-1020.3622)"> + transform="translate(0,-924.3622)"> <path - style="fill:#f7f5cf;fill-opacity:1;fill-rule:evenodd;stroke:#f7f5cf;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 16,1024.3622 0,24 -8,-8 -4,0 0,-8 4,0 z" + style="fill:#f7f5cf;fill-opacity:1;fill-rule:evenodd;stroke:#f7f5cf;stroke-width:8;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 64.000015,940.3622 0,96.0012 -31.999993,-32.0004 -15.999996,0 0,-32.00043 15.999996,0 z" id="path4143" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccccc" /> <rect style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" id="rect4145" - width="3" - height="8.0000172" - x="20" - y="1032.3622" /> + width="11.999997" + height="32.000439" + x="80.000008" + y="972.36255" /> <rect - y="1026.3622" - x="26" - height="19.999949" - width="3" + y="948.36224" + x="104" + height="80.000717" + width="11.999997" id="rect4147" style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843" /> + <circle + style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path4137" + cx="86" + cy="972.36218" + r="6" /> + <circle + r="6" + cy="1002.3622" + cx="86" + id="circle4139" + style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <circle + style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="circle4141" + cx="110" + cy="1028.3622" + r="6" /> + <circle + r="6" + cy="948.36218" + cx="110" + id="circle4143" + style="opacity:1;fill:#f7f5cf;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> </g> </svg> diff --git a/tools/editor/icons/source/icon_gizmo_spatial_stream_player.svg b/tools/editor/icons/source/icon_gizmo_spatial_stream_player.svg index 5acff1ec76..c333641249 100644 --- a/tools/editor/icons/source/icon_gizmo_spatial_stream_player.svg +++ b/tools/editor/icons/source/icon_gizmo_spatial_stream_player.svg @@ -9,9 +9,9 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="32" - height="32" - viewBox="0 0 32 32" + width="128" + height="128" + viewBox="0 0 128 128" id="svg2" version="1.1" inkscape:version="0.91 r13725" @@ -28,9 +28,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="15.999999" - inkscape:cx="18.768034" - inkscape:cy="16.106066" + inkscape:zoom="5.6568542" + inkscape:cx="102.18566" + inkscape:cy="68.674719" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -71,11 +71,11 @@ inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" - transform="translate(0,-1020.3622)"> + transform="translate(0,-924.3622)"> <path style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#f7f5cf;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="M 23.941406 2.0019531 A 2.0002 2.0002 0 0 0 23.451172 2.0761719 L 9.4511719 6.0761719 A 2.0002 2.0002 0 0 0 8 8 L 8 20.029297 A 4.5000086 4.5000086 0 0 0 7.5 20 A 4.5000086 4.5000086 0 0 0 3 24.5 A 4.5000086 4.5000086 0 0 0 7.5 29 A 4.5000086 4.5000086 0 0 0 11.96875 25 L 12 25 L 12 24.5 L 12 9.5097656 L 22 6.6523438 L 22 16.03125 A 4.5 4.5 0 0 0 21.5 16 A 4.5 4.5 0 0 0 17 20.5 A 4.5 4.5 0 0 0 21.5 25 A 4.5 4.5 0 0 0 25.96875 21 L 26 21 L 26 20.5 L 26 4 A 2.0002 2.0002 0 0 0 23.941406 2.0019531 z " - transform="translate(0,1020.3622)" - id="path4187" /> + d="m 99.765624,934.3602 a 8.0008,8.001126 0 0 0 -1.960936,0.296 l -56,16.0004 A 8.0008,8.001126 0 0 0 36,958.353 l 0,48.1192 a 18.000034,18.000768 0 0 0 -2,-0.116 18.000034,18.000768 0 0 0 -18,18.0008 18.000034,18.000768 0 0 0 18,18.0008 18.000034,18.000768 0 0 0 17.875,-16.0008 l 0.125,0 0,-2 0,-59.9632 40,-11.4304 0,37.5172 a 18,18.000734 0 0 0 -2,-0.124 18,18.000734 0 0 0 -18,18.0008 18,18.000734 0 0 0 18,18.0004 18,18.000734 0 0 0 17.875,-16.0004 l 0.125,0 0,-2 0,-66.0028 a 8.0008,8.001126 0 0 0 -8.234376,-7.9924 z" + id="path4187" + inkscape:connector-curvature="0" /> </g> </svg> diff --git a/tools/editor/icons/source/icon_zoom_more.svg b/tools/editor/icons/source/icon_zoom_more.svg new file mode 100644 index 0000000000..87acdfb021 --- /dev/null +++ b/tools/editor/icons/source/icon_zoom_more.svg @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + viewBox="0 0 16 16" + id="svg2" + version="1.1" + inkscape:version="0.91 r13725" + inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_zoom.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + sodipodi:docname="icon_zoom_more.svg"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="22.627417" + inkscape:cx="3.7772222" + inkscape:cy="13.690414" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + units="px" + inkscape:snap-bbox="true" + inkscape:bbox-paths="true" + inkscape:bbox-nodes="true" + inkscape:snap-bbox-edge-midpoints="true" + inkscape:snap-bbox-midpoints="false" + inkscape:snap-object-midpoints="true" + inkscape:snap-center="true" + inkscape:window-width="1920" + inkscape:window-height="1018" + inkscape:window-x="-8" + inkscape:window-y="-8" + inkscape:window-maximized="1"> + <inkscape:grid + type="xygrid" + id="grid3336" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1036.3622)"> + <g + id="layer1-6" + inkscape:label="Capa 1" + transform="translate(-201.5751,205.0256)"> + <g + inkscape:label="Layer 1" + id="layer1-0-4" + transform="matrix(48.459085,0,0,53.967813,-126.63031,-55835.691)"> + <g + transform="translate(0.51853114,-0.01988754)" + id="g4182-8"> + <rect + style="fill:#e0e0e0;fill-opacity:0.99607843" + id="rect4167" + width="0.042994563" + height="0.26204652" + x="6.3978949" + y="1050.0524" + rx="0" + ry="0" /> + <rect + ry="0" + rx="0" + y="1050.165" + x="6.2806396" + height="0.040943757" + width="0.28011176" + id="rect4169-6" + style="fill:#e0e0e0;fill-opacity:0.99607843" /> + </g> + </g> + </g> + </g> +</svg> diff --git a/tools/editor/import_settings.cpp b/tools/editor/import_settings.cpp deleted file mode 100644 index dfaeca03db..0000000000 --- a/tools/editor/import_settings.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/*************************************************************************/ -/* import_settings.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 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 "import_settings.h" -#include "os/os.h" -#include "editor_node.h" - -void ImportSettingsDialog::_item_pressed(int p_idx) { - - if (!edited) - return; - - String p=edited->get_metadata(0); -#if 0 - if (EditorImportDB::get_singleton()->is_image(p)) { - - uint32_t flags = EditorImportDB::get_singleton()->get_image_flags(p); - bool pressed = !popup->is_item_checked(p_idx); - if (pressed) - flags|=(1<<p_idx); - else - flags&=~(1<<p_idx); - - - EditorImportDB::get_singleton()->set_image_flags(p,flags); - edited->set_text(2,_str_from_flags(flags)); - } -#endif -} - -void ImportSettingsDialog::_item_edited() { - - if (updating) - return; - TreeItem *it=tree->get_selected(); - int ec=tree->get_edited_column(); - - String p=it->get_metadata(0); -#if 0 - if (EditorImportDB::get_singleton()->is_image(p)) { - - if (ec==1) { - - - EditorImportDB::get_singleton()->set_image_format(p,EditorImport::ImageFormat(int(it->get_range(1)))); - - } else if (ec==2) { - - - int flags = EditorImportDB::get_singleton()->get_image_flags(p); - for(int i=0;i<popup->get_item_count();i++) { - - popup->set_item_checked(i,flags&(1<<i)); - } - - Rect2 r = tree->get_custom_popup_rect(); - popup->set_size(Size2(r.size.width,1)); - popup->set_pos(/*tree->get_global_pos()+*/r.pos+Point2(0,r.size.height)); - popup->popup(); - } - - edited=it; - - } -#endif - - -} - - -void ImportSettingsDialog::_button_pressed(Object *p_button, int p_col, int p_id) { - - TreeItem *ti=p_button->cast_to<TreeItem>(); - if (!ti) - return; - String path = ti->get_metadata(0); - print_line("PATH: "+path); - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(path); - ERR_FAIL_COND(rimd.is_null()); - Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor()); - ERR_FAIL_COND(!rimp.is_valid()); - rimp->import_dialog(path); - hide(); -} - -bool ImportSettingsDialog::_generate_fs(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) { - - bool valid=false; - - - for(int i=0;i<p_dir->get_subdir_count();i++) { - - EditorFileSystemDirectory *sd=p_dir->get_subdir(i); - TreeItem *ti = tree->create_item(p_parent); - ti->set_text(0,sd->get_name()+"/"); - ti->set_icon(0,get_icon("Folder","EditorIcons")); - - if (!_generate_fs(ti,sd)) { - memdelete(ti); - } else { - valid=true; - } - } - - - for(int i=0;i<p_dir->get_file_count();i++) { - - String path=p_dir->get_file_path(i); - if (!p_dir->get_file_meta(i)) - continue; - - valid=true; - - String f = p_dir->get_file(i); - TreeItem *ti = tree->create_item(p_parent); - String type = p_dir->get_file_type(i); - Ref<Texture> t; - if (has_icon(type,"EditorIcons")) - t = get_icon(type,"EditorIcons"); - else - t = get_icon("Object","EditorIcons"); - - - ti->set_icon(0,t); - ti->set_text(0,f); -// ti->add_button(0,get_icon("Reload","EditorIcons")); - ti->set_metadata(0,p_dir->get_file_path(i)); - String tt = p_dir->get_file_path(i); - - if (p_dir->is_missing_sources(i)) { - ti->set_icon(1,get_icon("ImportFail","EditorIcons")); - Vector<String> missing = p_dir->get_missing_sources(i); - for(int j=0;j<missing.size();j++) { - tt+="\nmissing: "+missing[j]; - } - - } else - ti->set_icon(1,get_icon("ImportCheck","EditorIcons")); - - ti->set_tooltip(0,tt); - ti->set_tooltip(1,tt); - - } - -#if 0 - if (!EditorImportDB::get_singleton()->is_image(path) && !EditorImportDB::get_singleton()->is_scene(path)) - continue; - - String f = p_dir->get_file(i); - TreeItem *ti = tree->create_item(p_parent); - ti->set_text(0,f); - String type = p_dir->get_file_type(i); - Ref<Texture> icon = get_icon( (has_icon(type,"EditorIcons")?type:String("Object")),"EditorIcons"); - - - if (EditorImportDB::get_singleton()->is_image(path)) { - - - ti->set_tooltip(0,"Type: Image\nSource: "+EditorImportDB::get_singleton()->get_file_source(path)+"\nSource MD5: "+EditorImportDB::get_singleton()->get_file_md5(path)); - ti->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); - ti->set_editable(1,true); - ti->set_range_config(1,0,3,1); - ti->set_range(1,EditorImportDB::get_singleton()->get_image_format(path)); - ti->set_text(1,texformat); - ti->set_cell_mode(2,TreeItem::CELL_MODE_CUSTOM); - ti->set_editable(2,true); - ti->set_metadata(0,path); - - String txt; - uint32_t flags=EditorImportDB::get_singleton()->get_image_flags(path); - txt=_str_from_flags(flags); - - ti->set_text(2,txt); - } - - ti->set_icon(0, icon); - valid=true; -#endif - - - return valid; -} - -void ImportSettingsDialog::update_tree() { - - updating=true; - tree->clear(); - edited=NULL; - - - TreeItem *root = tree->create_item(); - EditorFileSystemDirectory *fs = EditorFileSystem::get_singleton()->get_filesystem(); - - _generate_fs(root,fs); - updating=false; - - -} - -void ImportSettingsDialog::_notification(int p_what) { - - if (p_what==NOTIFICATION_ENTER_TREE) { - - EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"update_tree"); - } -} - - -void ImportSettingsDialog::_bind_methods() { - - ObjectTypeDB::bind_method("update_tree",&ImportSettingsDialog::update_tree); - ObjectTypeDB::bind_method("_item_edited",&ImportSettingsDialog::_item_edited); - ObjectTypeDB::bind_method("_item_pressed",&ImportSettingsDialog::_item_pressed); - ObjectTypeDB::bind_method("_button_pressed",&ImportSettingsDialog::_button_pressed); - - -} - - -void ImportSettingsDialog::popup_import_settings() { - - update_tree(); - popup_centered_ratio(); -} - -void ImportSettingsDialog::ok_pressed() { - - - TreeItem *ti = tree->get_selected(); - if (!ti) - return; - - String path = ti->get_metadata(0); - print_line("PATH: "+path); - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(path); - ERR_FAIL_COND(rimd.is_null()); - Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor()); - ERR_FAIL_COND(!rimp.is_valid()); - rimp->import_dialog(path); - hide(); - - -} - -ImportSettingsDialog::ImportSettingsDialog(EditorNode *p_editor) { - - editor=p_editor; - - get_ok()->set_text(TTR("Close")); - - tree = memnew( Tree ); - add_child(tree); - set_child_rect(tree); - set_title(TTR("Imported Resources")); - -// texformat="Keep,None,Disk,VRAM"; - - tree->set_hide_root(true); - tree->set_columns(2); - tree->set_column_expand(1,false); - tree->set_column_min_width(1,20); - - tree->connect("item_edited",this,"_item_edited"); - tree->connect("button_pressed",this,"_button_pressed"); - -// add_button("Re-Import","reimport"); - get_ok()->set_text(TTR("Re-Import")); - get_cancel()->set_text(TTR("Close")); - - updating=false; - edited=NULL; - set_hide_on_ok(false); - - -} - diff --git a/tools/editor/io_plugins/editor_atlas.cpp b/tools/editor/io_plugins/editor_atlas.cpp index f894e7e8b2..f69e383fb0 100644 --- a/tools/editor/io_plugins/editor_atlas.cpp +++ b/tools/editor/io_plugins/editor_atlas.cpp @@ -82,7 +82,6 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S //place them int ofs=0; - int limit_h=0; for(int j=0;j<wrects.size();j++) { @@ -106,8 +105,6 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S int end_h = from_y+wrects[j].s.height; int end_w = ofs+wrects[j].s.width; - if (ofs==0) - limit_h=end_h; for(int k=0;k<wrects[j].s.width;k++) { @@ -120,8 +117,7 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S if (end_w > max_w) max_w=end_w; - //if (ofs==0 || end_h>limit_h ) //while h limit not reched, keep stacking - ofs+=wrects[j].s.width; + ofs+=wrects[j].s.width; } diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index 363cba3678..1130e2be30 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -2278,12 +2278,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones NodeMap &nm = node_map[at.target]; String path = scene->get_path_to(nm.node); - Collada::Node *cn = collada.state.scene_map[at.target]; - //if (cn->ignore_anim) { - // print_line("warning, ignoring property animation on node: "+nm.path); - //continue; - //} - animation->add_track(Animation::TYPE_VALUE); int track = animation->get_track_count() -1; @@ -2381,7 +2375,6 @@ Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_ state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS); AnimationPlayer *ap = memnew( AnimationPlayer ); - ap->set_name("animations"); for(int i=0;i<state.animations.size();i++) { String name; if (state.animations[i]->get_name()=="") diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp index 095c56a373..2c3ed2afd6 100644 --- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp @@ -520,7 +520,7 @@ Error EditorMeshImportPlugin::import(const String& p_path, const Ref<ResourceImp //new object/surface if (generate_normals || force_smooth) surf_tool->generate_normals(); - if (uvs.size() && (normals.size() || generate_normals)) + if (uvs.size() && (normals.size() || generate_normals) && generate_tangents) surf_tool->generate_tangents(); surf_tool->index(); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index c7d92a9658..e24412d4ef 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -822,7 +822,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { return; } if (wip_open) - EditorNode::get_singleton()->load_scene(save_file); + EditorNode::get_singleton()->load_scene(save_file,false,false,false); } @@ -867,7 +867,7 @@ void EditorSceneImportDialog::_import_confirm() { } if (wip_open) - EditorNode::get_singleton()->load_scene(wip_save_file); + EditorNode::get_singleton()->load_scene(wip_save_file,false,false,false); wip_open=false; wip_save_file=""; @@ -2459,7 +2459,7 @@ void EditorSceneImportPlugin::_optimize_animations(Node *scene, float p_max_lin_ void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node, bool p_merge_material, Map<String, Ref<Material> > &materials, bool p_merge_anims, Map<String,Ref<Animation> >& merged_anims,Set<Ref<Mesh> > &tested_meshes) { - if (node->get_owner()!=scene) + if (node!=scene && node->get_owner()!=scene) return; String path = scene->get_path_to(node); @@ -2507,11 +2507,43 @@ void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node, for(int i=0;i<mesh->get_surface_count();i++) { Ref<Material> material = mesh->surface_get_material(i); - materials[mesh->get_name()+":surf:"+mesh->surface_get_name(i)]=material; + + if (material.is_valid()) { + + String sname = mesh->surface_get_name(i); + if (sname=="") + sname="surf_"+itos(i); + + sname=mesh->get_name()+":surf:"+sname; + materials[sname]=material; + } } tested_meshes.insert(mesh); } + + if (mesh.is_valid()) { + + for(int i=0;i<mesh->get_surface_count();i++) { + Ref<Material> material = mi->get_surface_material(i); + if (material.is_valid()) { + String sname = mesh->surface_get_name(i); + if (sname=="") + sname="surf_"+itos(i); + + sname=path+":inst_surf:"+sname; + materials[sname]=material; + } + } + + } + + Ref<Material> override = mi->get_material_override(); + + if (override.is_valid()) { + + materials[path+":override"]=override; + } } @@ -2525,11 +2557,13 @@ void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node, void EditorSceneImportPlugin::_merge_found_resources(Node *scene, Node *node, bool p_merge_material, const Map<String, Ref<Material> > &materials, bool p_merge_anims, const Map<String,Ref<Animation> >& merged_anims, Set<Ref<Mesh> > &tested_meshes) { - if (node->get_owner()!=scene) + if (node!=scene && node->get_owner()!=scene) return; String path = scene->get_path_to(node); + print_line("at path: "+path); + if (node->cast_to<AnimationPlayer>()) { AnimationPlayer *ap = node->cast_to<AnimationPlayer>(); @@ -2570,15 +2604,48 @@ void EditorSceneImportPlugin::_merge_found_resources(Node *scene, Node *node, bo if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) { for(int i=0;i<mesh->get_surface_count();i++) { - String sname = mesh->get_name()+":surf:"+mesh->surface_get_name(i); + + String sname = mesh->surface_get_name(i); + if (sname=="") + sname="surf_"+itos(i); + + sname=mesh->get_name()+":surf:"+sname; + if (materials.has(sname)) { + mesh->surface_set_material(i,materials[sname]); } } tested_meshes.insert(mesh); } + + if (mesh.is_valid()) { + + for(int i=0;i<mesh->get_surface_count();i++) { + + String sname = mesh->surface_get_name(i); + if (sname=="") + sname="surf_"+itos(i); + + sname=path+":inst_surf:"+sname; + + + if (materials.has(sname)) { + + mi->set_surface_material(i,materials[sname]); + } + } + + } + + + String opath = path+":override"; + if (materials.has(opath)) { + mi->set_material_override(materials[opath]); + } + } @@ -2613,12 +2680,6 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c progress.step(TTR("Importing Scene.."),2); - bool reimport = bool(from->get_option("reimport")); - int this_time_action = from->get_option("import_this_time"); - int next_time_action = from->get_option("import_next_time"); - - int import_action = reimport?this_time_action:next_time_action; - from->set_source_md5(0,FileAccess::get_md5(src_path)); from->set_editor(get_name()); @@ -2627,8 +2688,6 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c Map<Ref<Mesh>,Ref<Shape> > collision_map; - Ref<ResourceImportMetadata> imd = memnew(ResourceImportMetadata); - Map< Ref<ImageTexture>,TextureRole > imagemap; scene=_fix_node(scene,scene,collision_map,scene_flags,imagemap); @@ -2643,6 +2702,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c if (scene_flags&(SCENE_FLAG_MERGE_KEEP_MATERIALS|SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS) && FileAccess::exists(p_dest_path)) { //must merge! + print_line("MUST MERGE"); Ref<PackedScene> pscene = ResourceLoader::load(p_dest_path,"PackedScene",true); if (pscene.is_valid()) { @@ -2653,8 +2713,9 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c Set<Ref<Mesh> > tested_meshes; _find_resources_to_merge(instance,instance,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes); + tested_meshes.clear(); - _merge_found_resources(instance,instance,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes); + _merge_found_resources(scene,scene,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes); memdelete(instance); } @@ -2680,8 +2741,9 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c post_import_script = Ref<EditorScenePostImport>( memnew( EditorScenePostImport ) ); post_import_script->set_script(scr.get_ref_ptr()); if (!post_import_script->get_script_instance()) { - EditorNode::add_io_error(TTR("Invalid/broken script for post-import:")+" "+post_import_script_path); + EditorNode::add_io_error(TTR("Invalid/broken script for post-import (check console):")+" "+post_import_script_path); post_import_script.unref(); + return ERR_CANT_CREATE; } } } @@ -2741,7 +2803,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c target_path=target_path.basename()+".tex"; Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - print_line("flags: "+itos(image_flags)); + uint32_t flags = image_flags; if (E->get()==TEXTURE_ROLE_DIFFUSE && scene_flags&SCENE_FLAG_LINEARIZE_DIFFUSE_TEXTURES) flags|=EditorTextureImportPlugin::IMAGE_FLAG_CONVERT_TO_LINEAR; @@ -2789,15 +2851,16 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c Ref<PackedScene> packer = memnew( PackedScene ); packer->pack(scene); - packer->set_path(p_dest_path); + //packer->set_path(p_dest_path); do not take over, let the changed files reload themselves packer->set_import_metadata(from); print_line("SAVING TO: "+p_dest_path); - err = ResourceSaver::save(p_dest_path,packer,ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); + err = ResourceSaver::save(p_dest_path,packer); //do not take over, let the changed files reload themselves //EditorFileSystem::get_singleton()->update_resource(packer); memdelete(scene); + /* scene->set_filename(p_dest_path); if (r_scene) { @@ -2817,6 +2880,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c */ + EditorNode::get_singleton()->reload_scene(p_dest_path); return err; diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 16ea803da4..60642999f2 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -147,8 +147,6 @@ void EditorImportTextureOptions::_changed() { void EditorImportTextureOptions::_bind_methods() { - print_line("bind toptions"); - ObjectTypeDB::bind_method("_changed",&EditorImportTextureOptions::_changed); ObjectTypeDB::bind_method("_changedp",&EditorImportTextureOptions::_changedp); @@ -1192,8 +1190,6 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc } ep.step(TTR("Converting Images"),sources.size()); - int base_index=0; - Map<uint64_t,int> source_md5; Map<int,List<int> > source_map; @@ -1760,7 +1756,6 @@ void EditorTextureImportPlugin::reimport_multiple_files(const Vector<String>& p_ Vector<String> valid; - bool warning=false; for(int i=0;i<p_list.size();i++) { Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_list[i]); @@ -1768,7 +1763,6 @@ void EditorTextureImportPlugin::reimport_multiple_files(const Vector<String>& p_ if (type=="texture" || type.begins_with("texture_")) { if ((rimd->has_option("atlas") && rimd->get_option("atlas")) || (rimd->has_option("large") && rimd->get_option("large"))) { - warning=true; continue; } diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.cpp b/tools/editor/io_plugins/editor_translation_import_plugin.cpp index aa36fefdb7..9ee3e98486 100644 --- a/tools/editor/io_plugins/editor_translation_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_translation_import_plugin.cpp @@ -425,7 +425,6 @@ Error EditorTranslationImportPlugin::import(const String& p_path, const Ref<Reso ERR_FAIL_COND_V( !f, ERR_INVALID_PARAMETER ); - bool first=false; bool skip_first = from->get_option("skip_first"); int index = from->get_option("index"); index+=1; @@ -439,7 +438,6 @@ Error EditorTranslationImportPlugin::import(const String& p_path, const Ref<Reso while(line.size()>1) { - if (!skip_first) { ERR_FAIL_INDEX_V(index,line.size(),ERR_INVALID_DATA ); translation->add_message(line[0].strip_edges(),line[index]); diff --git a/tools/editor/output_strings.cpp b/tools/editor/output_strings.cpp index f1b49d2326..a6126466c4 100644 --- a/tools/editor/output_strings.cpp +++ b/tools/editor/output_strings.cpp @@ -32,7 +32,6 @@ void OutputStrings::update_scrollbars() { - Size2 size = get_size(); Size2 hmin = h_scroll->get_combined_minimum_size(); Size2 vmin = v_scroll->get_combined_minimum_size(); diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index 10c7bf79a3..98ba25b482 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -407,7 +407,6 @@ void AnimationPlayerEditor::_animation_save(const Ref<Resource>& p_resource) { void AnimationPlayerEditor::_animation_save_as(const Ref<Resource>& p_resource) { file->set_mode(EditorFileDialog::MODE_SAVE_FILE); - bool relpaths = (p_resource->has_meta("__editor_relpaths__") && p_resource->get_meta("__editor_relpaths__").operator bool()); List<String> extensions; ResourceSaver::get_recognized_extensions(p_resource, &extensions); @@ -1404,6 +1403,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { hb->add_child(animation); animation->set_h_size_flags(SIZE_EXPAND_FILL); animation->set_tooltip(TTR("Display list of animations in player.")); + animation->set_clip_text(true); autoplay = memnew( ToolButton ); hb->add_child(autoplay); diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp index a381ec4678..24914e4bc5 100644 --- a/tools/editor/plugins/animation_tree_editor_plugin.cpp +++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp @@ -90,7 +90,6 @@ Size2 AnimationTreeEditor::get_node_size(const StringName& p_node) const { Ref<StyleBox> style = get_stylebox("panel","PopupMenu"); Ref<Font> font = get_font("font","PopupMenu"); - Color font_color = get_color("font_color","PopupMenu"); Size2 size = style->get_minimum_size(); @@ -633,7 +632,6 @@ AnimationTreeEditor::ClickType AnimationTreeEditor::_locate_click(const Point2& Ref<StyleBox> style = get_stylebox("panel","PopupMenu"); Ref<Font> font = get_font("font","PopupMenu"); - Color font_color = get_color("font_color","PopupMenu"); float h = (font->get_height()+get_constant("vseparation","PopupMenu")); diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index 1962f81e87..6a88ba4cbe 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -645,7 +645,6 @@ void BakedLightBaker::_octree_insert(int p_octant,Triangle* p_triangle, int p_de leaf_list=child_idx; cell_count++; - int lz = lights.size(); for(int ci=0;ci<8;ci++) { child->light_accum[ci][0]=0; child->light_accum[ci][1]=0; @@ -1016,8 +1015,6 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c //ray_aabb.expand_to(p_end); - const BVH *bvhptr = bvh; - bstack[0]=bvh; stack[0]=TEST_AABB_BIT; @@ -1693,7 +1690,7 @@ void BakedLightBaker::throw_rays(ThreadStack& thread_stack,int p_amount) { Vector3 from = dl.pos; double r1 = double(rand())/RAND_MAX; - double r2 = double(rand())/RAND_MAX; + //double r2 = double(rand())/RAND_MAX; double r3 = double(rand())/RAND_MAX; float d=Math::tan(Math::deg2rad(dl.spot_angle)); @@ -1994,7 +1991,6 @@ void BakedLightBaker::update_octree_images(DVector<uint8_t> &p_octree,DVector<ui const double *normptr=norm_arr.ptr(); */ double norm = 1.0/double(total_rays); - int lz=lights.size(); mult/=multiplier; double saturation = baked_light->get_saturation(); @@ -2261,8 +2257,6 @@ void BakedLightBaker::_plot_pixel_to_lightmap(int x, int y, int width, int heigh continue; n/=len; - const BVH *bvhptr = bvh; - bstack[0]=bvh; stack[0]=TEST_RAY_BIT; @@ -2404,8 +2398,6 @@ Error BakedLightBaker::transfer_to_lightmaps() { float gamma = baked_light->get_gamma_adjust(); float mult = baked_light->get_energy_multiplier(); - - const double *normptr=norm_arr.ptr(); for(int i=0;i<triangles.size();i++) { if (i%200==0) { @@ -2538,7 +2530,6 @@ Error BakedLightBaker::transfer_to_lightmaps() { Vector<uint8_t> copy_data=bt.data; uint8_t *data=bt.data.ptr(); - uint8_t *src_data=copy_data.ptr(); const int max_radius=8; const int shadow_radius=2; const int max_dist=0x7FFFFFFF; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 0cbc867b47..f9499904db 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -1382,6 +1382,8 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { se->undo_state=canvas_item->edit_get_state(); if (canvas_item->cast_to<Node2D>()) se->undo_pivot=canvas_item->cast_to<Node2D>()->edit_get_pivot(); + if (canvas_item->cast_to<Control>()) + se->undo_pivot=Vector2(); return; } @@ -1566,14 +1568,34 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { if (drag==DRAG_ROTATE) { Vector2 center = canvas_item->get_global_transform_with_canvas().get_origin(); - if (Node2D *node = canvas_item->cast_to<Node2D>()) { - Matrix32 rot; - rot.elements[1] = (dfrom - center).normalized(); - rot.elements[0] = rot.elements[1].tangent(); - node->set_rot(snap_angle(rot.xform_inv(dto-center).angle() + node->get_rot(), node->get_rot())); - display_rotate_to = dto; - display_rotate_from = center; - viewport->update(); + { + Node2D *node = canvas_item->cast_to<Node2D>(); + + + if (node) { + Matrix32 rot; + rot.elements[1] = (dfrom - center).normalized(); + rot.elements[0] = rot.elements[1].tangent(); + node->set_rot(snap_angle(rot.xform_inv(dto-center).angle() + node->get_rot(), node->get_rot())); + display_rotate_to = dto; + display_rotate_from = center; + viewport->update(); + } + } + + { + Control *node = canvas_item->cast_to<Control>(); + + + if (node) { + Matrix32 rot; + rot.elements[1] = (dfrom - center).normalized(); + rot.elements[0] = rot.elements[1].tangent(); + node->set_rotation(snap_angle(rot.xform_inv(dto-center).angle() + node->get_rotation(), node->get_rotation())); + display_rotate_to = dto; + display_rotate_from = center; + viewport->update(); + } } continue; @@ -1918,8 +1940,6 @@ void CanvasItemEditor::_viewport_draw() { Map<Node*,Object*> &selection = editor_selection->get_selection(); - CanvasItem *single_item=NULL; - bool pivot_found=false; for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) { @@ -1939,15 +1959,6 @@ void CanvasItemEditor::_viewport_draw() { Matrix32 xform=transform * canvas_item->get_global_transform_with_canvas(); VisualServer::get_singleton()->canvas_item_add_set_transform(ci,xform); - Point2 ofs=Point2();//get_global_pos(); - Rect2 draw_rect=rect; - Color light_edit_color=Color(1.0,0.8,0.8); - Color dark_edit_color=Color(0.4,0.1,0.1); - Size2 handle_size=Size2(handle_len,handle_len); - - //select_sb->draw(ci,draw_rect.grow(2)); - //DRAW_EMPTY_RECT( draw_rect.grow(2), light_edit_color ); - //DRAW_EMPTY_RECT( draw_rect.grow(1), dark_edit_color ); Vector2 endpoints[4]={ @@ -3352,25 +3363,25 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { PopupMenu *p; p = edit_menu->get_popup(); - p->add_check_item(TTR("Use Snap"),SNAP_USE); - p->add_check_item(TTR("Show Grid"),SNAP_SHOW_GRID); - p->add_check_item(TTR("Use Rotation Snap"),SNAP_USE_ROTATION); - p->add_check_item(TTR("Snap Relative"),SNAP_RELATIVE); - p->add_item(TTR("Configure Snap.."),SNAP_CONFIGURE); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_snap", TTR("Use Snap")), SNAP_USE); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Show Grid")), SNAP_SHOW_GRID); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_rotation_snap", TTR("Use Rotation Snap")), SNAP_USE_ROTATION); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_relative", TTR("Snap Relative")), SNAP_RELATIVE); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/configure_snap", TTR("Configure Snap..")), SNAP_CONFIGURE); p->add_separator(); - p->add_check_item(TTR("Use Pixel Snap"),SNAP_USE_PIXEL); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_pixel_snap", TTR("Use Pixel Snap")), SNAP_USE_PIXEL); p->add_separator(); - p->add_item(TTR("Expand to Parent"),EXPAND_TO_PARENT,KEY_MASK_CMD|KEY_P); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/expand_to_parent", TTR("Expand to Parent"), KEY_MASK_CMD | KEY_P), EXPAND_TO_PARENT); p->add_separator(); p->add_submenu_item(TTR("Skeleton.."),"skeleton"); PopupMenu *p2 = memnew(PopupMenu); p->add_child(p2); p2->set_name("skeleton"); - p2->add_item(TTR("Make Bones"),SKELETON_MAKE_BONES,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_B); - p2->add_item(TTR("Clear Bones"),SKELETON_CLEAR_BONES); + p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTR("Make Bones"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B ),SKELETON_MAKE_BONES); + p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_bones", TTR("Clear Bones")), SKELETON_CLEAR_BONES); p2->add_separator(); - p2->add_item(TTR("Make IK Chain"),SKELETON_SET_IK_CHAIN); - p2->add_item(TTR("Clear IK Chain"),SKELETON_CLEAR_IK_CHAIN); + p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_set_ik_chain", TTR("Make IK Chain")), SKELETON_SET_IK_CHAIN); + p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_ik_chain", TTR("Clear IK Chain")), SKELETON_CLEAR_IK_CHAIN); p2->connect("item_pressed", this,"_popup_callback"); @@ -3387,13 +3398,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p = view_menu->get_popup(); - p->add_item(TTR("Zoom In"),ZOOM_IN); - p->add_item(TTR("Zoom Out"),ZOOM_OUT); - p->add_item(TTR("Zoom Reset"),ZOOM_RESET); - p->add_item(TTR("Zoom Set.."),ZOOM_SET); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_in", TTR("Zoom In")), ZOOM_IN); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_out", TTR("Zoom Out")), ZOOM_OUT); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_reset", TTR("Zoom Reset")), ZOOM_RESET); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_set", TTR("Zoom Set..")), ZOOM_SET); p->add_separator(); - p->add_item(TTR("Center Selection"), VIEW_CENTER_TO_SELECTION, KEY_F); - p->add_item(TTR("Frame Selection"), VIEW_FRAME_TO_SELECTION, KEY_MASK_CMD|KEY_F); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTR("Center Selection"), KEY_F), VIEW_CENTER_TO_SELECTION); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/frame_selection", TTR("Frame Selection"), KEY_MASK_SHIFT | KEY_F), VIEW_FRAME_TO_SELECTION); anchor_menu = memnew( MenuButton ); anchor_menu->set_text(TTR("Anchor")); @@ -3436,7 +3447,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_insert_button = memnew( Button ); key_insert_button->set_focus_mode(FOCUS_NONE); key_insert_button->connect("pressed",this,"_popup_callback",varray(ANIM_INSERT_KEY)); - key_insert_button->set_tooltip(TTR("Insert Keys (Ins)")); + key_insert_button->set_tooltip(TTR("Insert Keys")); + key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT)); animation_hb->add_child(key_insert_button); @@ -3447,12 +3459,12 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p = animation_menu->get_popup(); - p->add_item(TTR("Insert Key"),ANIM_INSERT_KEY,KEY_INSERT); - p->add_item(TTR("Insert Key (Existing Tracks)"),ANIM_INSERT_KEY_EXISTING,KEY_MASK_CMD+KEY_INSERT); + p->add_shortcut(ED_GET_SHORTCUT("canvas_item_editor/anim_insert_key"), ANIM_INSERT_KEY); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key_existing_tracks", TTR("Insert Key (Existing Tracks)"), KEY_MASK_CMD+KEY_INSERT), ANIM_INSERT_KEY_EXISTING); p->add_separator(); - p->add_item(TTR("Copy Pose"),ANIM_COPY_POSE); - p->add_item(TTR("Paste Pose"),ANIM_PASTE_POSE); - p->add_item(TTR("Clear Pose"),ANIM_CLEAR_POSE,KEY_MASK_SHIFT|KEY_K); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_copy_pose", TTR("Copy Pose")), ANIM_COPY_POSE); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_paste_pose", TTR("Paste Pose")), ANIM_PASTE_POSE); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_clear_pose", TTR("Clear Pose"), KEY_MASK_SHIFT | KEY_K), ANIM_CLEAR_POSE); snap_dialog = memnew( SnapDialog ); snap_dialog->connect("confirmed",this,"_snap_changed"); diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 5ed9f8ab5f..95364e8921 100644 --- a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -349,8 +349,6 @@ void CollisionPolygon2DEditor::_canvas_draw() { Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Ref<Texture> handle= get_icon("EditorHandle","EditorIcons"); - int len = poly.size(); - for(int i=0;i<poly.size();i++) { diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp index b18afe7838..0b06b3ba21 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp @@ -381,8 +381,6 @@ void CollisionPolygonEditor::_polygon_draw() { poly=node->get_polygon(); - - int len = poly.size(); float depth = node->get_depth()*0.5; imgeom->clear(); @@ -586,7 +584,7 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) { handle_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1)); handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, false); - Ref<Texture> handle= SpatialEditor::get_singleton()->get_icon("Editor3DHandle","EditorIcons"); + Ref<Texture> handle=editor->get_gui_base()->get_icon("Editor3DHandle","EditorIcons"); handle_material->set_point_size(handle->get_width()); handle_material->set_texture(FixedMaterial::PARAM_DIFFUSE,handle); diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index a057e6c2a1..b1bce60484 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -36,6 +36,7 @@ #include "scene/resources/mesh.h" #include "scene/resources/bit_mask.h" #include "tools/editor/editor_scale.h" + bool EditorTexturePreviewPlugin::handles(const String& p_type) const { return (ObjectTypeDB::is_type(p_type,"ImageTexture") || ObjectTypeDB::is_type(p_type, "AtlasTexture")); @@ -442,7 +443,6 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES& p_from) { Color keyword_color = EditorSettings::get_singleton()->get("text_editor/keyword_color"); Color text_color = EditorSettings::get_singleton()->get("text_editor/text_color"); Color symbol_color = EditorSettings::get_singleton()->get("text_editor/symbol_color"); - Color comment_color = EditorSettings::get_singleton()->get("text_editor/comment_color"); for(int i=0;i<thumbnail_size;i++) { @@ -607,7 +607,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { -1, -1, -1, -1, 2, 4, 6, 8 }; - int16_t nibble,signed_nibble,diff,step; + int16_t nibble,diff,step; ima_adpcm.last_nibble++; const uint8_t *src_ptr=sdata; @@ -628,10 +628,6 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { if (ima_adpcm.step_index>88) ima_adpcm.step_index=88; - /* - signed_nibble = (nibble&7) * ((nibble&8)?-1:1); - diff = (2 * signed_nibble + 1) * step / 4; */ - diff = step >> 3 ; if (nibble & 1) diff += step >> 2 ; @@ -748,15 +744,13 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int j=0;j<h;j++) { - int half,ofs; + int half; float v; if (j<(h/2)) { half=0; - ofs=0; v = (j/(float)(h/2)) * 2.0 - 1.0; } else { half=1; - ofs=h/2; if( (float)(h/2) != 0 ) { v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0; } else { diff --git a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp index 14e7b14fc3..56e58bc983 100644 --- a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -364,8 +364,6 @@ void LightOccluder2DEditor::_canvas_draw() { Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Ref<Texture> handle= get_icon("EditorHandle","EditorIcons"); - int len = poly.size(); - for(int i=0;i<poly.size();i++) { diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp index 5a8cd8791e..22546c72f3 100644 --- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -427,8 +427,6 @@ void NavigationPolygonEditor::_canvas_draw() { poly = Variant(node->get_navigation_polygon()->get_outline(j)); } - int len = poly.size(); - for(int i=0;i<poly.size();i++) { diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp index 93e2fb2f38..7e20cc3f54 100644 --- a/tools/editor/plugins/particles_editor_plugin.cpp +++ b/tools/editor/plugins/particles_editor_plugin.cpp @@ -283,7 +283,6 @@ void ParticlesEditor::_generate_emission_points() { ofs=(Vector3(1,1,1)-dir)*Vector3(Math::randf(),Math::randf(),Math::randf())*aabb.size; ofs+=aabb.pos; - Vector3 dirv = -dir; Vector3 ofsv = ofs + aabb.size * dir; //space it a little diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp index d78508c429..19d1ccc06f 100644 --- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp @@ -466,8 +466,6 @@ void Polygon2DEditor::_canvas_draw() { Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Ref<Texture> handle= get_icon("EditorHandle","EditorIcons"); - int len = poly.size(); - for(int i=0;i<poly.size();i++) { diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index b094184a29..7965fa54ae 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -151,7 +151,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag -1, -1, -1, -1, 2, 4, 6, 8 }; - int16_t nibble,signed_nibble,diff,step; + int16_t nibble,diff,step; ima_adpcm.last_nibble++; const uint8_t *src_ptr=sdata; @@ -172,10 +172,6 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag if (ima_adpcm.step_index>88) ima_adpcm.step_index=88; - /* - signed_nibble = (nibble&7) * ((nibble&8)?-1:1); - diff = (2 * signed_nibble + 1) * step / 4; */ - diff = step >> 3 ; if (nibble & 1) diff += step >> 2 ; @@ -285,15 +281,13 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag for(int j=0;j<h;j++) { - int half,ofs; + int half; float v; if (j<(h/2)) { half=0; - ofs=0; v = (j/(float)(h/2)) * 2.0 - 1.0; } else { half=1; - ofs=h/2; v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0; } @@ -324,12 +318,13 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag void SampleEditor::_update_sample() { player->stop_all(); - if (sample->get_format()==Sample::FORMAT_IMA_ADPCM) - return; //bye or unsupported generate_preview_texture(sample,peakdisplay); info_label->set_text(TTR("Length:")+" "+String::num(sample->get_length()/(float)sample->get_mix_rate(),2)+"s"); + if (library->has_sample("default")) + library->remove_sample("default"); + library->add_sample("default",sample); } diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 10e4fc8475..65741fd072 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -43,6 +43,28 @@ /*** SCRIPT EDITOR ****/ +static bool _can_open_in_editor(Script* p_script) { + + String path = p_script->get_path(); + + if (path.find("::")!=-1) { + //refuse handling this if it can't be edited + + bool valid=false; + for(int i=0;i<EditorNode::get_singleton()->get_editor_data().get_edited_scene_count();i++) { + if (path.begins_with(EditorNode::get_singleton()->get_editor_data().get_scene_path(i))) { + valid=true; + break; + } + } + + return valid; + } + + return true; +} + + class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache { @@ -290,9 +312,12 @@ void ScriptTextEditor::_load_theme_settings() { get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0))); get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244"))); get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf"))); + get_text_edit()->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/completion_scroll_color", Color::html("ffffff"))); + get_text_edit()->add_color_override("completion_font_color", EDITOR_DEF("text_editor/completion_font_color", Color::html("aaaaaa"))); get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0))); get_text_edit()->add_color_override("line_number_color",EDITOR_DEF("text_editor/line_number_color",Color(0,0,0))); get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0))); + get_text_edit()->add_color_override("caret_background_color",EDITOR_DEF("text_editor/caret_background_color",Color(0,0,0))); get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1))); get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1))); get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2))); @@ -585,7 +610,6 @@ void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>* Error err = script->get_language()->complete_code(p_code,script->get_path().get_base_dir(),base,r_options,hint); if (hint!="") { get_text_edit()->set_code_hint(hint); - print_line("hint: "+hint.replace(String::chr(0xFFFF),"|")); } } @@ -748,9 +772,9 @@ void ScriptEditor::_go_to_tab(int p_idx) { _update_script_colors(); } -void ScriptEditor::_close_current_tab() { +void ScriptEditor::_close_tab(int p_idx) { - int selected = tab_container->get_current_tab(); + int selected = p_idx; if (selected<0 || selected>=tab_container->get_child_count()) return; @@ -796,6 +820,11 @@ void ScriptEditor::_close_current_tab() { _update_script_names(); EditorNode::get_singleton()->save_layout(); +} + +void ScriptEditor::_close_current_tab() { + + _close_tab(tab_container->get_current_tab()); } @@ -848,6 +877,15 @@ void ScriptEditor::_reload_scripts(){ } + 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) { + continue; + } + + 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() ); @@ -975,6 +1013,18 @@ void ScriptEditor::swap_lines(TextEdit *tx, int line1, int line2) tx->cursor_set_line(line2); } +void ScriptEditor::_breakpoint_toggled(const int p_row) { + int selected = tab_container->get_current_tab(); + if (selected<0 || selected>=tab_container->get_child_count()) { + return; + } + + ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>(); + if (current) { + get_debugger()->set_breakpoint(current->get_edited_script()->get_path(),p_row+1,current->get_text_edit()->is_line_set_as_breakpoint(p_row)); + } +} + void ScriptEditor::_file_dialog_action(String p_file) { switch (file_dialog_option) { @@ -1682,6 +1732,33 @@ void ScriptEditor::_notification(int p_what) { } + +void ScriptEditor::close_builtin_scripts_from_scene(const String& p_scene) { + + + + for(int i=0;i<tab_container->get_child_count();i++) { + + ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); + + if (ste) { + + Ref<Script> script = ste->get_edited_script(); + if (!script.is_valid()) + continue; + + if (script->get_path().find("::")!=-1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed + _close_tab(i); + i--; + + } + } + + } + + +} + void ScriptEditor::edited_scene_changed() { _update_modified_scripts_for_external_editor(); @@ -2060,11 +2137,18 @@ void ScriptEditor::_update_script_names() { } + + void ScriptEditor::edit(const Ref<Script>& p_script) { if (p_script.is_null()) return; + // refuse to open built-in if scene is not loaded + + + + // see if already has it bool open_dominant = EditorSettings::get_singleton()->get("text_editor/open_dominant_script_on_scene_change"); @@ -2124,9 +2208,11 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { ste->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); ste->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); ste->get_text_edit()->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter")); + ste->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); ste->get_text_edit()->set_callhint_settings( EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"), EditorSettings::get_singleton()->get("text_editor/callhint_tooltip_offset")); + ste->get_text_edit()->connect("breakpoint_toggled", this, "_breakpoint_toggled"); tab_container->add_child(ste); _go_to_tab(tab_container->get_tab_count()-1); @@ -2291,6 +2377,7 @@ void ScriptEditor::_editor_settings_changed() { ste->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); ste->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); ste->get_text_edit()->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter")); + ste->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); } ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/auto_reload_and_parse_scripts_on_save",true)); @@ -2316,6 +2403,22 @@ void ScriptEditor::_script_split_dragged(float) { EditorNode::get_singleton()->save_layout(); } +void ScriptEditor::_unhandled_input(const InputEvent& p_event) { + if (p_event.key.pressed || !is_visible()) return; + if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) { + int next_tab = script_list->get_current() + 1; + next_tab %= script_list->get_item_count(); + _go_to_tab(script_list->get_item_metadata(next_tab)); + _update_script_names(); + } + if (ED_IS_SHORTCUT("script_editor/prev_script", p_event)) { + int next_tab = script_list->get_current() - 1; + next_tab = next_tab >= 0 ? next_tab : script_list->get_item_count() - 1; + _go_to_tab(script_list->get_item_metadata(next_tab)); + _update_script_names(); + } +} + void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { if (!bool(EDITOR_DEF("text_editor/restore_scripts_on_load",true))) { @@ -2335,6 +2438,8 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { for(int i=0;i<scripts.size();i++) { String path = scripts[i]; + if (!FileAccess::exists(path)) + continue; Ref<Script> scr = ResourceLoader::load(path); if (scr.is_valid()) { edit(scr); @@ -2512,7 +2617,7 @@ void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) { if (bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor"))) return; - if (open_dominant && p_script.is_valid()) { + if (open_dominant && p_script.is_valid() && _can_open_in_editor(p_script.ptr())) { edit(p_script); } } @@ -2582,6 +2687,7 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_res_saved_callback",&ScriptEditor::_res_saved_callback); ObjectTypeDB::bind_method("_goto_script_line",&ScriptEditor::_goto_script_line); ObjectTypeDB::bind_method("_goto_script_line2",&ScriptEditor::_goto_script_line2); + ObjectTypeDB::bind_method("_breakpoint_toggled", &ScriptEditor::_breakpoint_toggled); ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); ObjectTypeDB::bind_method("_show_debugger",&ScriptEditor::_show_debugger); ObjectTypeDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip); @@ -2598,6 +2704,7 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_history_forward",&ScriptEditor::_history_forward); ObjectTypeDB::bind_method("_history_back",&ScriptEditor::_history_back); ObjectTypeDB::bind_method("_live_auto_reload_running_scripts",&ScriptEditor::_live_auto_reload_running_scripts); + ObjectTypeDB::bind_method("_unhandled_input",&ScriptEditor::_unhandled_input); } @@ -2631,6 +2738,10 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { tab_container->set_h_size_flags(SIZE_EXPAND_FILL); + ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_GREATER); + ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_LESS); + set_process_unhandled_input(true); + file_menu = memnew( MenuButton ); menu_hb->add_child(file_menu); file_menu->set_text(TTR("File")); @@ -2895,6 +3006,16 @@ void ScriptEditorPlugin::edit(Object *p_object) { bool ScriptEditorPlugin::handles(Object *p_object) const { + if (p_object->cast_to<Script>()) { + + bool valid = _can_open_in_editor(p_object->cast_to<Script>()); + + if (!valid) { //user tried to open it by clicking + EditorNode::get_singleton()->show_warning(TTR("Built-in scripts can only be edited when the scene they belong to is loaded")); + } + return valid; + } + return p_object->is_type("Script"); } diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index 0636190a41..dfa72490a5 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -234,6 +234,8 @@ class ScriptEditor : public VBoxContainer { bool _test_script_times_on_disk(Ref<Script> p_for_script=Ref<Script>()); + void _close_tab(int p_idx); + void _close_current_tab(); bool grab_focus_block; @@ -279,6 +281,8 @@ class ScriptEditor : public VBoxContainer { void _script_split_dragged(float); + void _unhandled_input(const InputEvent& p_event); + void _history_forward(); void _history_back(); @@ -317,6 +321,7 @@ public: void get_breakpoints(List<String> *p_breakpoints); void swap_lines(TextEdit *tx, int line1, int line2); + void _breakpoint_toggled(const int p_row); void save_all_scripts(); @@ -329,6 +334,8 @@ public: virtual void edited_scene_changed(); + void close_builtin_scripts_from_scene(const String& p_scene); + ScriptEditorDebugger *get_debugger() { return debugger; } void set_live_auto_reload_running_scripts(bool p_enabled); diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index 76042c3028..b3317e8313 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -81,9 +81,12 @@ void ShaderTextEditor::_load_theme_settings() { get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0))); get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244"))); get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf"))); + get_text_edit()->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/completion_scroll_color", Color::html("ffffff"))); + get_text_edit()->add_color_override("completion_font_color", EDITOR_DEF("text_editor/completion_font_color", Color::html("aaaaaa"))); get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0))); get_text_edit()->add_color_override("line_number_color",EDITOR_DEF("text_editor/line_number_color",Color(0,0,0))); get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0))); + get_text_edit()->add_color_override("caret_background_color",EDITOR_DEF("text_editor/caret_background_color",Color(0,0,0))); get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1))); get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1))); get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2))); @@ -118,9 +121,10 @@ void ShaderTextEditor::_load_theme_settings() { get_text_edit()->add_color_region("/*","*/",comment_color,false); get_text_edit()->add_color_region("//","",comment_color,false); - //colorize strings + + /*//colorize strings Color string_color = EDITOR_DEF("text_editor/string_color",Color::hex(0x6b6f00ff)); - /* + List<String> strings; shader->get_shader_mode()->get_string_delimiters(&strings); @@ -378,6 +382,7 @@ void ShaderEditor::_editor_settings_changed() { vertex_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); vertex_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); vertex_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/line_spacing")); + vertex_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); fragment_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); fragment_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); @@ -389,6 +394,7 @@ void ShaderEditor::_editor_settings_changed() { fragment_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); fragment_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); fragment_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/line_spacing")); + fragment_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); light_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); light_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); @@ -400,6 +406,7 @@ void ShaderEditor::_editor_settings_changed() { light_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); light_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); light_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/line_spacing")); + light_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); } void ShaderEditor::_bind_methods() { @@ -499,7 +506,7 @@ ShaderEditor::ShaderEditor() { edit_menu->set_pos(Point2(5,-1)); edit_menu->set_text(TTR("Edit")); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/undo", TTR("Undo"), KEY_MASK_CMD|KEY_Z), EDIT_UNDO); - edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_Z), EDIT_REDO); + edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_Y), EDIT_REDO); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/cut", TTR("Cut"), KEY_MASK_CMD|KEY_X), EDIT_CUT); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy", TTR("Copy"), KEY_MASK_CMD|KEY_C), EDIT_COPY); @@ -519,7 +526,7 @@ ShaderEditor::ShaderEditor() { search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/replace", TTR("Replace.."), KEY_MASK_CMD|KEY_R), SEARCH_REPLACE); search_menu->get_popup()->add_separator(); // search_menu->get_popup()->add_item("Locate Symbol..",SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K); - search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_G), SEARCH_GOTO_LINE); + search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_L), SEARCH_GOTO_LINE); search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp index d567c8e9b3..375220051c 100644 --- a/tools/editor/plugins/shader_graph_editor_plugin.cpp +++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp @@ -176,7 +176,9 @@ void GraphColorRampEdit::_input_event(const InputEvent& p_event) { void GraphColorRampEdit::_notification(int p_what){ if (p_what==NOTIFICATION_ENTER_TREE) { - picker->connect("color_changed",this,"_color_changed"); + if (!picker->is_connected("color_changed",this,"_color_changed")) { + picker->connect("color_changed",this,"_color_changed"); + } } if (p_what==NOTIFICATION_DRAW) { @@ -184,9 +186,8 @@ void GraphColorRampEdit::_notification(int p_what){ Point prev; prev.offset=0; prev.color=Color(0,0,0); - int w = get_size().x; - int h = get_size().y; + int h = get_size().y; int total_w = get_size().width-get_size().height-3; for(int i=-1;i<points.size();i++) { diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 8d72178f23..a70df78697 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -53,8 +53,6 @@ void SpatialEditorViewport::_update_camera() { if (orthogonal) { - Size2 size = get_size(); - Size2 vpsize = Point2(cursor.distance*size.get_aspect(), cursor.distance / size.get_aspect()); //camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar()); camera->set_orthogonal(2 * cursor.distance, 0.1, 8192); } @@ -79,21 +77,30 @@ void SpatialEditorViewport::_update_camera() { String SpatialEditorGizmo::get_handle_name(int p_idx) const { + if (get_script_instance() && get_script_instance()->has_method("get_handle_name")) + return get_script_instance()->call("get_handle_name", p_idx); + return ""; } Variant SpatialEditorGizmo::get_handle_value(int p_idx) const{ + if (get_script_instance() && get_script_instance()->has_method("get_handle_value")) + return get_script_instance()->call("get_handle_value", p_idx); + return Variant(); } void SpatialEditorGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point) { + if (get_script_instance() && get_script_instance()->has_method("set_handle")) + get_script_instance()->call("set_handle", p_idx, p_camera, p_point); } void SpatialEditorGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){ - + if (get_script_instance() && get_script_instance()->has_method("commit_handle")) + get_script_instance()->call("commit_handle", p_idx, p_restore, p_cancel); } bool SpatialEditorGizmo::intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum) { @@ -276,10 +283,6 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b r_includes_current=false; List<_RayResult> results; - Vector3 cn=_get_camera_normal(); - Plane cplane(pos,cn.normalized()); - - float min_d=1e20; for (int i=0;i<instances.size();i++) { @@ -649,21 +652,8 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2& p_screenpos,bool p_hili Vector3 ray_pos=_get_ray_pos( Vector2( p_screenpos.x, p_screenpos.y ) ); Vector3 ray=_get_ray( Vector2( p_screenpos.x, p_screenpos.y ) ); - Vector3 cn=_get_camera_normal(); - Plane cplane(ray_pos,cn.normalized()); - Transform gt = spatial_editor->get_gizmo_transform(); float gs=gizmo_scale; - /* - if (orthogonal) { - gs= cursor.distance/surface->get_size().get_aspect(); - - } else { - gs = cplane.distance_to(gt.origin); - } - - gs*=GIZMO_SCALE_DEFAULT; -*/ if (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_MOVE) { @@ -1268,16 +1258,6 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (_edit.gizmo.is_valid()) { - Plane plane=Plane(_edit.gizmo_initial_pos,_get_camera_normal()); - - - Vector3 ray_pos=_get_ray_pos( Vector2( m.x, m.y ) ); - Vector3 ray=_get_ray( Vector2( m.x, m.y ) ); - - //Vector3 intersection; - //if (!plane.intersects_ray(ray_pos,ray,&intersection)) - // break; - _edit.gizmo->set_handle(_edit.gizmo_handle,camera,Vector2(m.x,m.y)); Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle); String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle); @@ -1658,136 +1638,89 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { default: {} } } break; - case InputEvent::KEY: { - const InputEventKey &k = p_event.key; if (!k.pressed) break; - switch(k.scancode) { - - case KEY_S: { - - if (_edit.mode!=TRANSFORM_NONE) { - - _edit.snap=true; - } - } break; - case KEY_7: - case KEY_KP_7: { - bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad"); - if (!emulate_numpad && k.scancode==KEY_7) - return; - cursor.y_rot=0; - if (k.mod.shift) { - cursor.x_rot=-Math_PI/2.0; - set_message(TTR("Bottom View."),2); - name=TTR("Bottom"); - _update_name(); - - } else { - cursor.x_rot=Math_PI/2.0; - set_message(TTR("Top View."),2); - name=TTR("Top"); - _update_name(); - } - } break; - case KEY_1: - case KEY_KP_1: { - bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad"); - if (!emulate_numpad && k.scancode==KEY_1) - return; - cursor.x_rot=0; - if (k.mod.shift) { - cursor.y_rot=Math_PI; - set_message(TTR("Rear View."),2); - name=TTR("Rear"); - _update_name(); - - } else { - cursor.y_rot=0; - set_message(TTR("Front View."),2); - name=TTR("Front"); - _update_name(); - } - - } break; - case KEY_3: - case KEY_KP_3: { - bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad"); - if (!emulate_numpad && k.scancode==KEY_3) - return; - cursor.x_rot=0; - if (k.mod.shift) { - cursor.y_rot=Math_PI/2.0; - set_message(TTR("Left View."),2); - name=TTR("Left"); - _update_name(); - } else { - cursor.y_rot=-Math_PI/2.0; - set_message(TTR("Right View."),2); - name=TTR("Right"); - _update_name(); - } - - } break; - case KEY_5: - case KEY_KP_5: { - bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad"); - if (!emulate_numpad && k.scancode==KEY_5) - return; - - //orthogonal = !orthogonal; - _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL); - _update_name(); - - - } break; - case KEY_K: { - - if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE) - break; - - if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) { - set_message(TTR("Keying is disabled (no key inserted).")); - break; - } - - List<Node*> &selection = editor_selection->get_selected_node_list(); - - for(List<Node*>::Element *E=selection.front();E;E=E->next()) { - - Spatial *sp = E->get()->cast_to<Spatial>(); - if (!sp) - continue; - - emit_signal("transform_key_request",sp,"",sp->get_transform()); - } - - - set_message(TTR("Animation Key Inserted.")); + if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) { + if (_edit.mode != TRANSFORM_NONE) { + _edit.snap=true; + } + } + if (ED_IS_SHORTCUT("spatial_editor/bottom_view", p_event)) { + cursor.y_rot = 0; + cursor.x_rot = -Math_PI/2.0; + set_message(TTR("Bottom View."),2); + name = TTR("Bottom"); + _update_name(); + } + if (ED_IS_SHORTCUT("spatial_editor/top_view", p_event)) { + cursor.y_rot = 0; + cursor.x_rot = Math_PI/2.0; + set_message(TTR("Top View."),2); + name = TTR("Top"); + _update_name(); + } + if (ED_IS_SHORTCUT("spatial_editor/rear_view", p_event)) { + cursor.x_rot = 0; + cursor.y_rot = Math_PI; + set_message(TTR("Rear View."),2); + name = TTR("Rear"); + _update_name(); + } + if (ED_IS_SHORTCUT("spatial_editor/front_view", p_event)) { + cursor.x_rot = 0; + cursor.y_rot=0; + set_message(TTR("Front View."),2); + name=TTR("Front"); + _update_name(); + } + if (ED_IS_SHORTCUT("spatial_editor/left_view", p_event)) { + cursor.x_rot=0; + cursor.y_rot = Math_PI/2.0; + set_message(TTR("Left View."),2); + name = TTR("Left"); + _update_name(); + } + if (ED_IS_SHORTCUT("spatial_editor/right_view", p_event)) { + cursor.x_rot=0; + cursor.y_rot = -Math_PI/2.0; + set_message(TTR("Right View."),2); + name = TTR("Right"); + _update_name(); + } + if (ED_IS_SHORTCUT("spatial_editor/switch_perspective_orthogonal", p_event)) { + _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL); + _update_name(); + } + if (ED_IS_SHORTCUT("spatial_editor/insert_anim_key", p_event)) { + if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE) + break; + if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) { + set_message(TTR("Keying is disabled (no key inserted).")); + break; + } - } break; + List<Node*> &selection = editor_selection->get_selected_node_list(); - case KEY_F: { + for(List<Node*>::Element *E=selection.front();E;E=E->next()) { - if (k.pressed && k.mod.shift && k.mod.control) { - _menu_option(VIEW_ALIGN_SELECTION_WITH_VIEW); - } else if (k.pressed) { - _menu_option(VIEW_CENTER_TO_SELECTION); - } + Spatial *sp = E->get()->cast_to<Spatial>(); + if (!sp) + continue; - } break; + emit_signal("transform_key_request",sp,"",sp->get_transform()); + } - case KEY_SPACE: { - if (!k.pressed) - emit_signal("toggle_maximize_view", this); - } break; + set_message(TTR("Animation Key Inserted.")); } + if (k.scancode == KEY_SPACE) { + if (!k.pressed) emit_signal("toggle_maximize_view", this); + } } break; @@ -1855,16 +1788,6 @@ void SpatialEditorViewport::_notification(int p_what) { continue; - /* - ?? - if (!se->poly_instance.is_valid()) - continue; - if (!ObjectDB::get_instance( E->key() )) { - VisualServer::get_singleton()->free( se->poly_instance ); - se->poly_instance=RID(); - continue; - } - */ VisualInstance *vi=sp->cast_to<VisualInstance>(); @@ -1902,35 +1825,6 @@ void SpatialEditorViewport::_notification(int p_what) { surface->update(); } - //grid - Vector3 grid_cam_axis=_get_camera_normal(); - /* - for(int i=0;i<3;i++) { - - - Vector3 axis; - axis[i]=1; - - bool should_be_visible= grid_enabled && (grid_enable[i] || (Math::abs(grid_cam_axis.dot(axis))>0.99 && orthogonal)); - - if (should_be_visible!=grid_visible[i]) { - - VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,should_be_visible); - grid_visible[i]=should_be_visible; - } - } - - if (last_grid_snap!=spatial_editor->get_translate_snap()) { - - - last_grid_snap=spatial_editor->get_translate_snap() - Transform gridt; - gridt.basis.scale(Vector3(last_grid_snap,last_grid_snap,last_grid_snap)); - for(int i=0;i<3;i++) - VisualServer::get_singleton()->instance_set_transform(grid_instance[i],gridt); - - }*/ - } if (p_what==NOTIFICATION_ENTER_TREE) { @@ -2470,29 +2364,28 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed surface->add_child(view_menu); view_menu->set_pos( Point2(4,4)); view_menu->set_self_opacity(0.5); - - view_menu->get_popup()->add_item(TTR("Top (Num7)"),VIEW_TOP); - view_menu->get_popup()->add_item(TTR("Bottom (Shift+Num7)"),VIEW_BOTTOM); - view_menu->get_popup()->add_item(TTR("Left (Num3)"),VIEW_LEFT); - view_menu->get_popup()->add_item(TTR("Right (Shift+Num3)"),VIEW_RIGHT); - view_menu->get_popup()->add_item(TTR("Front (Num1)"),VIEW_FRONT); - view_menu->get_popup()->add_item(TTR("Rear (Shift+Num1)"),VIEW_REAR); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/right_view"), VIEW_RIGHT); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/front_view"), VIEW_FRONT); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/rear_view"), VIEW_REAR); view_menu->get_popup()->add_separator(); - view_menu->get_popup()->add_check_item(TTR("Perspective (Num5)"),VIEW_PERSPECTIVE); - view_menu->get_popup()->add_check_item(TTR("Orthogonal (Num5)"),VIEW_ORTHOGONAL); + view_menu->get_popup()->add_check_item(TTR("Perspective") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_PERSPECTIVE); + view_menu->get_popup()->add_check_item(TTR("Orthogonal") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_ORTHOGONAL); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE),true); view_menu->get_popup()->add_separator(); - view_menu->get_popup()->add_check_item(TTR("Environment"),VIEW_ENVIRONMENT); + view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("Environment")), VIEW_ENVIRONMENT); view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT),true); view_menu->get_popup()->add_separator(); - view_menu->get_popup()->add_check_item(TTR("Audio Listener"),VIEW_AUDIO_LISTENER); + view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTR("Audio Listener")), VIEW_AUDIO_LISTENER); view_menu->get_popup()->add_separator(); - view_menu->get_popup()->add_check_item(TTR("Gizmos"),VIEW_GIZMOS); + view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("Gizmos")),VIEW_GIZMOS); view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_GIZMOS),true); view_menu->get_popup()->add_separator(); - view_menu->get_popup()->add_item(TTR("Selection (F)"),VIEW_CENTER_TO_SELECTION); - view_menu->get_popup()->add_item(TTR("Align with view (Ctrl+Shift+F)"),VIEW_ALIGN_SELECTION_WITH_VIEW); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_selection_with_view"), VIEW_ALIGN_SELECTION_WITH_VIEW); view_menu->get_popup()->connect("item_pressed",this,"_menu_option"); preview_camera = memnew( Button ); @@ -2613,16 +2506,9 @@ Object *SpatialEditor::_get_editor_data(Object *p_what) { si->sbox_instance=VisualServer::get_singleton()->instance_create2(selection_box->get_rid(),sp->get_world()->get_scenario()); VS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, VS::SHADOW_CASTING_SETTING_OFF); - RID inst = sp->call("_get_visual_instance_rid"); - -// if (inst.is_valid()) -// si->aabb = VisualServer::get_singleton()->instance_get_base_aabb(inst); - - if (get_tree()->is_editor_hint()) editor->call("edit_node",sp); - return si; } @@ -3951,6 +3837,19 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child(vs); + ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT+KEY_KP_7); + ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7); + ED_SHORTCUT("spatial_editor/rear_view", TTR("Rear View"), KEY_MASK_ALT+KEY_KP_1); + ED_SHORTCUT("spatial_editor/front_view", TTR("Front View"), KEY_KP_1); + ED_SHORTCUT("spatial_editor/left_view", TTR("Left View"), KEY_MASK_ALT+KEY_KP_3); + ED_SHORTCUT("spatial_editor/right_view", TTR("Right View"), KEY_KP_3); + ED_SHORTCUT("spatial_editor/switch_perspective_orthogonal", TTR("Switch Perspective/Orthogonal view"), KEY_KP_5); + ED_SHORTCUT("spatial_editor/snap", TTR("Snap"), KEY_S); + ED_SHORTCUT("spatial_editor/insert_anim_key", TTR("Insert Animation Key"), KEY_K); + ED_SHORTCUT("spatial_editor/focus_selection", TTR("Focus Selection"), KEY_F); + ED_SHORTCUT("spatial_editor/align_selection_with_view", TTR("Align Selection With View"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_F); + + PopupMenu *p; transform_menu = memnew( MenuButton ); @@ -3958,13 +3857,13 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child( transform_menu ); p = transform_menu->get_popup(); - p->add_check_item(TTR("Use Snap"),MENU_TRANSFORM_USE_SNAP); - p->add_item(TTR("Configure Snap.."),MENU_TRANSFORM_CONFIGURE_SNAP); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_snap", TTR("Use Snap")), MENU_TRANSFORM_USE_SNAP); + p->add_shortcut(ED_SHORTCUT("spatial_editor/configure_snap", TTR("Configure Snap..")), MENU_TRANSFORM_CONFIGURE_SNAP); p->add_separator(); - p->add_check_item(TTR("Local Coords"),MENU_TRANSFORM_LOCAL_COORDS); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Local Coords")), MENU_TRANSFORM_LOCAL_COORDS); //p->set_item_checked(p->get_item_count()-1,true); p->add_separator(); - p->add_item(TTR("Transform Dialog.."),MENU_TRANSFORM_DIALOG); + p->add_shortcut(ED_SHORTCUT("spatial_editor/transform_dialog", TTR("Transform Dialog..")), MENU_TRANSFORM_DIALOG); p->connect("item_pressed", this,"_menu_item_pressed"); @@ -3975,27 +3874,27 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { p = view_menu->get_popup(); - p->add_check_item(TTR("Use Default Light"),MENU_VIEW_USE_DEFAULT_LIGHT); - p->add_check_item(TTR("Use Default sRGB"),MENU_VIEW_USE_DEFAULT_SRGB); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_default_light", TTR("Use Default Light")), MENU_VIEW_USE_DEFAULT_LIGHT); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_default_srgb", TTR("Use Default sRGB")), MENU_VIEW_USE_DEFAULT_SRGB); p->add_separator(); - p->add_check_item(TTR("1 Viewport"),MENU_VIEW_USE_1_VIEWPORT,KEY_MASK_CMD+KEY_1); - p->add_check_item(TTR("2 Viewports"),MENU_VIEW_USE_2_VIEWPORTS,KEY_MASK_CMD+KEY_2); - p->add_check_item(TTR("2 Viewports (Alt)"),MENU_VIEW_USE_2_VIEWPORTS_ALT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_2); - p->add_check_item(TTR("3 Viewports"),MENU_VIEW_USE_3_VIEWPORTS,KEY_MASK_CMD+KEY_3); - p->add_check_item(TTR("3 Viewports (Alt)"),MENU_VIEW_USE_3_VIEWPORTS_ALT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_3); - p->add_check_item(TTR("4 Viewports"),MENU_VIEW_USE_4_VIEWPORTS,KEY_MASK_CMD+KEY_4); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTR("1 Viewport"), KEY_MASK_CMD+KEY_1), MENU_VIEW_USE_1_VIEWPORT); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTR("2 Viewports"), KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTR("2 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS_ALT); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports", TTR("3 Viewports"),KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports_alt", TTR("3 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS_ALT); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/4_viewports", TTR("4 Viewports"), KEY_MASK_CMD+KEY_4), MENU_VIEW_USE_4_VIEWPORTS); p->add_separator(); - p->add_check_item(TTR("Display Normal"),MENU_VIEW_DISPLAY_NORMAL); - p->add_check_item(TTR("Display Wireframe"),MENU_VIEW_DISPLAY_WIREFRAME); - p->add_check_item(TTR("Display Overdraw"),MENU_VIEW_DISPLAY_OVERDRAW); - p->add_check_item(TTR("Display Shadeless"),MENU_VIEW_DISPLAY_SHADELESS); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_normal", TTR("Display Normal")), MENU_VIEW_DISPLAY_NORMAL); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_wireframe", TTR("Display Wireframe")), MENU_VIEW_DISPLAY_WIREFRAME); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_overdraw", TTR("Display Overdraw")), MENU_VIEW_DISPLAY_OVERDRAW); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_shadeless", TTR("Display Shadeless")), MENU_VIEW_DISPLAY_SHADELESS); p->add_separator(); - p->add_check_item(TTR("View Origin"),MENU_VIEW_ORIGIN); - p->add_check_item(TTR("View Grid"),MENU_VIEW_GRID); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_origin", TTR("View Origin")), MENU_VIEW_ORIGIN); + p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_grid", TTR("View Grid")), MENU_VIEW_GRID); p->add_separator(); - p->add_item(TTR("Settings"),MENU_VIEW_CAMERA_SETTINGS); + p->add_shortcut(ED_SHORTCUT("spatial_editor/settings", TTR("Settings")), MENU_VIEW_CAMERA_SETTINGS); p->set_item_checked( p->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT), true ); diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp index 4f59287994..e29a0c8d52 100644 --- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp @@ -31,7 +31,7 @@ #include "io/resource_loader.h" #include "globals.h" #include "tools/editor/editor_settings.h" - +#include "scene/3d/sprite_3d.h" @@ -355,6 +355,35 @@ void SpriteFramesEditor::_animation_select() { } + +static void _find_anim_sprites(Node* p_node,List<Node*> *r_nodes,Ref<SpriteFrames> p_sfames) { + + Node *edited = EditorNode::get_singleton()->get_edited_scene(); + if (!edited) + return; + if (p_node!=edited && p_node->get_owner()!=edited) + return; + + { + AnimatedSprite *as = p_node->cast_to<AnimatedSprite>(); + if (as && as->get_sprite_frames()==p_sfames) { + r_nodes->push_back(p_node); + } + } + + { + AnimatedSprite3D *as = p_node->cast_to<AnimatedSprite3D>(); + if (as && as->get_sprite_frames()==p_sfames) { + r_nodes->push_back(p_node); + } + } + + for(int i=0;i<p_node->get_child_count();i++) { + _find_anim_sprites(p_node->get_child(i),r_nodes,p_sfames); + } + +} + void SpriteFramesEditor::_animation_name_edited(){ if (updating) @@ -381,9 +410,24 @@ void SpriteFramesEditor::_animation_name_edited(){ name=new_name+" "+itos(counter); } + List<Node*> nodes; + _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(),&nodes,Ref<SpriteFrames>(frames)); + undo_redo->create_action(TTR("Rename Animation")); undo_redo->add_do_method(frames,"rename_animation",edited_anim,name); undo_redo->add_undo_method(frames,"rename_animation",name,edited_anim); + + for(List<Node*>::Element *E=nodes.front();E;E=E->next()) { + + String current = E->get()->call("get_animation"); + if (current!=edited_anim) + continue; + + undo_redo->add_do_method(E->get(),"set_animation",name); + undo_redo->add_undo_method(E->get(),"set_animation",edited_anim); + + } + undo_redo->add_do_method(this,"_update_library"); undo_redo->add_undo_method(this,"_update_library"); @@ -406,12 +450,28 @@ void SpriteFramesEditor::_animation_add(){ name=new_name+" "+itos(counter); } + List<Node*> nodes; + _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(),&nodes,Ref<SpriteFrames>(frames)); + + undo_redo->create_action(TTR("Add Animation")); undo_redo->add_do_method(frames,"add_animation",name); undo_redo->add_undo_method(frames,"remove_animation",name); undo_redo->add_do_method(this,"_update_library"); undo_redo->add_undo_method(this,"_update_library"); + + for(List<Node*>::Element *E=nodes.front();E;E=E->next()) { + + String current = E->get()->call("get_animation"); + if (frames->has_animation(current)) + continue; + + undo_redo->add_do_method(E->get(),"set_animation",name); + undo_redo->add_undo_method(E->get(),"set_animation",current); + + } + edited_anim=new_name; undo_redo->commit_action(); @@ -426,6 +486,7 @@ void SpriteFramesEditor::_animation_remove(){ if (!frames->has_animation(edited_anim)) return; + undo_redo->create_action(TTR("Remove Animation")); undo_redo->add_do_method(frames,"remove_animation",edited_anim); undo_redo->add_undo_method(frames,"add_animation",edited_anim); diff --git a/tools/editor/plugins/texture_region_editor_plugin.cpp b/tools/editor/plugins/texture_region_editor_plugin.cpp index 57db19b736..63d8e2e1cf 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.cpp +++ b/tools/editor/plugins/texture_region_editor_plugin.cpp @@ -29,21 +29,30 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "core/core_string_names.h" #include "texture_region_editor_plugin.h" #include "scene/gui/check_box.h" #include "os/input.h" #include "os/keyboard.h" +void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to){ + Vector2 line = (to-from).normalized() * 10; + while ((to - from).length_squared() > 200) { + edit_draw->draw_line(from, from + line,Color(0.97, 0.2, 0.2),2); + from += line*2; + } +} + void TextureRegionEditor::_region_draw() { Ref<Texture> base_tex = NULL; - if(node_type == "Sprite" && node_sprite) + if(node_sprite) base_tex = node_sprite->get_texture(); - else if(node_type == "Patch9Frame" && node_patch9) + else if(node_patch9) base_tex = node_patch9->get_texture(); - else if(node_type == "StyleBoxTexture" && obj_styleBox) + else if(obj_styleBox.is_valid()) base_tex = obj_styleBox->get_texture(); - else if(node_type == "AtlasTexture" && atlas_tex) + else if(atlas_tex.is_valid()) base_tex = atlas_tex->get_atlas(); if (base_tex.is_null()) return; @@ -57,29 +66,63 @@ void TextureRegionEditor::_region_draw() edit_draw->draw_texture(base_tex,Point2()); VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(),Matrix32()); - if (snap_show_grid) { + if (snap_mode == SNAP_GRID) { Size2 s = edit_draw->get_size(); int last_cell; if (snap_step.x!=0) { - for(int i=0;i<s.width;i++) { - int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i,0)).x-snap_offset.x)/snap_step.x)); - if (i==0) + if (snap_separation.x == 0) + for(int i=0;i<s.width;i++) { + int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i,0)).x-snap_offset.x)/snap_step.x)); + if (i==0) + last_cell=cell; + if (last_cell!=cell) + edit_draw->draw_line(Point2(i,0),Point2(i,s.height),Color(0.3,0.7,1,0.3)); last_cell=cell; - if (last_cell!=cell) - edit_draw->draw_line(Point2(i,0),Point2(i,s.height),Color(0.3,0.7,1,0.3)); - last_cell=cell; - } + } + else + for(int i=0;i<s.width;i++) { + int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i,0)).x-snap_offset.x)/(snap_step.x+snap_separation.x))); + if (i==0) + last_cell=cell; + if (last_cell!=cell) + edit_draw->draw_rect(Rect2(i-snap_separation.x*draw_zoom,0,snap_separation.x*draw_zoom,s.height),Color(0.3,0.7,1,0.3)); + last_cell=cell; + } } if (snap_step.y!=0) { - for(int i=0;i<s.height;i++) { - int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0,i)).y-snap_offset.y)/snap_step.y)); - if (i==0) + if (snap_separation.y == 0) + for(int i=0;i<s.height;i++) { + int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0,i)).y-snap_offset.y)/snap_step.y)); + if (i==0) + last_cell=cell; + if (last_cell!=cell) + edit_draw->draw_line(Point2(0,i),Point2(s.width,i),Color(0.3,0.7,1,0.3)); last_cell=cell; - if (last_cell!=cell) - edit_draw->draw_line(Point2(0,i),Point2(s.width,i),Color(0.3,0.7,1,0.3)); - last_cell=cell; + } + else + for(int i=0;i<s.height;i++) { + int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0,i)).y-snap_offset.y)/(snap_step.y+snap_separation.y))); + if (i==0) + last_cell=cell; + if (last_cell!=cell) + edit_draw->draw_rect(Rect2(0,i-snap_separation.y*draw_zoom,s.width,snap_separation.y*draw_zoom),Color(0.3,0.7,1,0.3)); + last_cell=cell; + } + } + } else if (snap_mode == SNAP_AUTOSLICE) { + for (List<Rect2>::Element *E = autoslice_cache.front();E;E=E->next()) { + Rect2 r = E->get(); + Vector2 endpoints[4]={ + mtx.basis_xform(r.pos), + mtx.basis_xform(r.pos+Vector2(r.size.x,0)), + mtx.basis_xform(r.pos+r.size), + mtx.basis_xform(r.pos+Vector2(0,r.size.y)) + }; + for(int i=0;i<4;i++) { + int next = (i+1)%4; + edit_draw->draw_line(endpoints[i]-draw_ofs, endpoints[next]-draw_ofs, Color(0.3,0.7,1,1) , 2); } } } @@ -96,8 +139,6 @@ void TextureRegionEditor::_region_draw() mtx.basis_xform(rect.pos+Vector2(0,rect.size.y)) }; Color color(0.9,0.5,0.5); - if(this->editing_region == REGION_PATCH_MARGIN) - color = Color(0.21, 0.79, 0.31); for(int i=0;i<4;i++) { int prev = (i+3)%4; @@ -108,12 +149,14 @@ void TextureRegionEditor::_region_draw() edit_draw->draw_line(endpoints[i]-draw_ofs, endpoints[next]-draw_ofs, color , 2); - edit_draw->draw_texture(select_handle,(endpoints[i]+ofs-(select_handle->get_size()/2)).floor()-draw_ofs); + if (snap_mode != SNAP_AUTOSLICE) + edit_draw->draw_texture(select_handle,(endpoints[i]+ofs-(select_handle->get_size()/2)).floor()-draw_ofs); ofs = (endpoints[next]-endpoints[i])/2; ofs += (endpoints[next]-endpoints[i]).tangent().normalized()*(select_handle->get_size().width/2); - edit_draw->draw_texture(select_handle,(endpoints[i]+ofs-(select_handle->get_size()/2)).floor()-draw_ofs); + if (snap_mode != SNAP_AUTOSLICE) + edit_draw->draw_texture(select_handle,(endpoints[i]+ofs-(select_handle->get_size()/2)).floor()-draw_ofs); scroll_rect.expand_to(endpoints[i]); } @@ -132,6 +175,31 @@ void TextureRegionEditor::_region_draw() vscroll->set_val(draw_ofs.y); vscroll->set_step(0.001); updating_scroll=false; + + float margins[4]; + if (node_patch9 || obj_styleBox.is_valid()) { + if (node_patch9) { + margins[0] = node_patch9->get_patch_margin(MARGIN_TOP); + margins[1] = node_patch9->get_patch_margin(MARGIN_BOTTOM); + margins[2] = node_patch9->get_patch_margin(MARGIN_LEFT); + margins[3] = node_patch9->get_patch_margin(MARGIN_RIGHT); + } else if (obj_styleBox.is_valid()) { + margins[0] = obj_styleBox->get_margin_size(MARGIN_TOP); + margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM); + margins[2] = obj_styleBox->get_margin_size(MARGIN_LEFT); + margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT); + } + Vector2 pos[4] = { + mtx.basis_xform(Vector2(0,margins[0]))+Vector2(0,endpoints[0].y-draw_ofs.y), + -mtx.basis_xform(Vector2(0,margins[1]))+Vector2(0,endpoints[2].y-draw_ofs.y), + mtx.basis_xform(Vector2(margins[2],0))+Vector2(endpoints[0].x-draw_ofs.x,0), + -mtx.basis_xform(Vector2(margins[3],0))+Vector2(endpoints[2].x-draw_ofs.x,0)}; + + draw_margin_line(edit_draw,pos[0],pos[0]+Vector2(edit_draw->get_size().x,0)); + draw_margin_line(edit_draw,pos[1],pos[1]+Vector2(edit_draw->get_size().x,0)); + draw_margin_line(edit_draw,pos[2],pos[2]+Vector2(0,edit_draw->get_size().y)); + draw_margin_line(edit_draw,pos[3],pos[3]+Vector2(0,edit_draw->get_size().y)); + } } void TextureRegionEditor::_region_input(const InputEvent& p_input) @@ -153,84 +221,174 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input) if (p_input.type==InputEvent::MOUSE_BUTTON) { - const InputEventMouseButton &mb=p_input.mouse_button; if (mb.button_index==BUTTON_LEFT) { - if (mb.pressed) { - - drag_from=mtx.affine_inverse().xform(Vector2(mb.x,mb.y)); - drag_from=snap_point(drag_from); - drag=true; - if(node_type == "Sprite" && node_sprite ) - rect_prev=node_sprite->get_region_rect(); - else if(node_type == "AtlasTexture" && atlas_tex) - rect_prev=atlas_tex->get_region(); - else if(node_type == "Patch9Frame" && node_patch9) - rect_prev=node_patch9->get_region_rect(); - else if(node_type == "StyleBoxTexture" && obj_styleBox) - rect_prev=obj_styleBox->get_region_rect(); - - drag_index=-1; - for(int i=0;i<8;i++) { - - Vector2 tuv=endpoints[i]; - if (tuv.distance_to(Vector2(mb.x,mb.y))<8) { - drag_index=i; - creating = false; + if (node_patch9 || obj_styleBox.is_valid()) { + edited_margin = -1; + float margins[4]; + if (node_patch9) { + margins[0] = node_patch9->get_patch_margin(MARGIN_TOP); + margins[1] = node_patch9->get_patch_margin(MARGIN_BOTTOM); + margins[2] = node_patch9->get_patch_margin(MARGIN_LEFT); + margins[3] = node_patch9->get_patch_margin(MARGIN_RIGHT); + } else if (obj_styleBox.is_valid()) { + margins[0] = obj_styleBox->get_margin_size(MARGIN_TOP); + margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM); + margins[2] = obj_styleBox->get_margin_size(MARGIN_LEFT); + margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT); + } + Vector2 pos[4] = { + mtx.basis_xform(rect.pos+Vector2(0,margins[0]))-draw_ofs, + mtx.basis_xform(rect.pos+rect.size-Vector2(0,margins[1]))-draw_ofs, + mtx.basis_xform(rect.pos+Vector2(margins[2],0))-draw_ofs, + mtx.basis_xform(rect.pos+rect.size-Vector2(margins[3],0))-draw_ofs}; + if (Math::abs(mb.y - pos[0].y) < 8) { + edited_margin = 0; + prev_margin = margins[0]; + } else if (Math::abs(mb.y - pos[1].y) < 8) { + edited_margin = 1; + prev_margin = margins[1]; + } else if (Math::abs(mb.x - pos[2].x) < 8) { + edited_margin = 2; + prev_margin = margins[2]; + } else if (Math::abs(mb.x - pos[3].x) < 8) { + edited_margin = 3; + prev_margin = margins[3]; + } + if (edited_margin >= 0) { + drag_from=Vector2(mb.x,mb.y); + drag=true; } } + if ( edited_margin < 0 && snap_mode == SNAP_AUTOSLICE) { + Vector2 point = mtx.affine_inverse().xform(Vector2(mb.x,mb.y)); + for (List<Rect2>::Element *E=autoslice_cache.front();E;E=E->next()) { + if (E->get().has_point(point)) { + rect = E->get(); + if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)&&!(Input::get_singleton()->is_key_pressed(KEY_SHIFT|KEY_ALT))) { + Rect2 r; + if(node_sprite ) + r=node_sprite->get_region_rect(); + else if(node_patch9) + r=node_patch9->get_region_rect(); + else if(obj_styleBox.is_valid()) + r=obj_styleBox->get_region_rect(); + else if(atlas_tex.is_valid()) + r =atlas_tex->get_region(); + rect.expand_to(r.pos); + rect.expand_to(r.pos+r.size); + } + undo_redo->create_action("Set Region Rect"); + if(node_sprite){ + undo_redo->add_do_method(node_sprite ,"set_region_rect",rect); + undo_redo->add_undo_method(node_sprite,"set_region_rect",node_sprite->get_region_rect()); + } else if(node_patch9){ + undo_redo->add_do_method(node_patch9 ,"set_region_rect",rect); + undo_redo->add_undo_method(node_patch9,"set_region_rect",node_patch9->get_region_rect()); + } else if (obj_styleBox.is_valid()) { + undo_redo->add_do_method(obj_styleBox.ptr(),"set_region_rect",rect); + undo_redo->add_undo_method(obj_styleBox.ptr(),"set_region_rect",obj_styleBox->get_region_rect()); + } else if (atlas_tex.is_valid()) { + undo_redo->add_do_method(atlas_tex.ptr(),"set_region",rect); + undo_redo->add_undo_method(atlas_tex.ptr(),"set_region",atlas_tex->get_region()); + } + undo_redo->add_do_method(edit_draw,"update"); + undo_redo->add_undo_method(edit_draw,"update"); + undo_redo->commit_action(); + break; + } + } + } else if (edited_margin < 0) { + drag_from=mtx.affine_inverse().xform(Vector2(mb.x,mb.y)); + if (snap_mode == SNAP_PIXEL) + drag_from = drag_from.snapped(Vector2(1,1)); + else if (snap_mode == SNAP_GRID) + drag_from=snap_point(drag_from); + drag=true; + if(node_sprite ) + rect_prev=node_sprite->get_region_rect(); + else if(node_patch9) + rect_prev=node_patch9->get_region_rect(); + else if(obj_styleBox.is_valid()) + rect_prev=obj_styleBox->get_region_rect(); + else if(atlas_tex.is_valid()) + rect_prev=atlas_tex->get_region(); + + for (int i=0; i<8;i++) { + Vector2 tuv=endpoints[i]; + if (tuv.distance_to(Vector2(mb.x,mb.y))<8) { + drag_index=i; + } + } - if (drag_index==-1) { - creating = true; - rect = Rect2(drag_from,Size2()); + if (drag_index==-1) { + creating = true; + rect = Rect2(drag_from,Size2()); + } } } else if (drag) { - if(editing_region == REGION_TEXTURE_REGION) { - undo_redo->create_action("Set region_rect"); - if(node_type == "Sprite" && node_sprite ){ + if (edited_margin >= 0) { + undo_redo->create_action("Set Margin"); + static Margin m[4] = {MARGIN_TOP,MARGIN_BOTTOM,MARGIN_LEFT,MARGIN_RIGHT}; + if (node_patch9) { + undo_redo->add_do_method(node_patch9 ,"set_patch_margin",m[edited_margin],node_patch9->get_patch_margin(m[edited_margin])); + undo_redo->add_undo_method(node_patch9,"set_patch_margin",m[edited_margin],prev_margin); + } else if (obj_styleBox.is_valid()) { + undo_redo->add_do_method(obj_styleBox.ptr() ,"set_margin_size",m[edited_margin],obj_styleBox->get_margin_size(m[edited_margin])); + undo_redo->add_undo_method(obj_styleBox.ptr(),"set_margin_size",m[edited_margin],prev_margin); + obj_styleBox->emit_signal(CoreStringNames::get_singleton()->changed); + } + edited_margin = -1; + } else { + undo_redo->create_action("Set Region Rect"); + if(node_sprite){ undo_redo->add_do_method(node_sprite ,"set_region_rect",node_sprite->get_region_rect()); undo_redo->add_undo_method(node_sprite,"set_region_rect",rect_prev); } - else if(node_type == "AtlasTexture" && atlas_tex ){ - undo_redo->add_do_method(atlas_tex ,"set_region",atlas_tex->get_region()); - undo_redo->add_undo_method(atlas_tex,"set_region",rect_prev); + else if(atlas_tex.is_valid()){ + undo_redo->add_do_method(atlas_tex.ptr() ,"set_region",atlas_tex->get_region()); + undo_redo->add_undo_method(atlas_tex.ptr(),"set_region",rect_prev); } - else if(node_type == "Patch9Frame" && node_patch9){ + else if(node_patch9){ + } else if(node_patch9){ undo_redo->add_do_method(node_patch9 ,"set_region_rect",node_patch9->get_region_rect()); undo_redo->add_undo_method(node_patch9,"set_region_rect",rect_prev); + } else if (obj_styleBox.is_valid()) { + undo_redo->add_do_method(obj_styleBox.ptr() ,"set_region_rect",obj_styleBox->get_region_rect()); + undo_redo->add_undo_method(obj_styleBox.ptr(),"set_region_rect",rect_prev); } - else if(node_type == "StyleBoxTexture" && obj_styleBox){ - undo_redo->add_do_method(obj_styleBox ,"set_region_rect",obj_styleBox->get_region_rect()); - undo_redo->add_undo_method(obj_styleBox,"set_region_rect",rect_prev); - } - undo_redo->add_do_method(edit_draw,"update"); - undo_redo->add_undo_method(edit_draw,"update"); - undo_redo->commit_action(); + drag_index = -1; } + undo_redo->add_do_method(edit_draw,"update"); + undo_redo->add_undo_method(edit_draw,"update"); + undo_redo->commit_action(); drag=false; + creating = false; } } else if (mb.button_index==BUTTON_RIGHT && mb.pressed) { if (drag) { drag=false; - apply_rect(rect_prev); - rect=rect_prev; - edit_draw->update(); + if (edited_margin >= 0) { + static Margin m[4] = {MARGIN_TOP,MARGIN_BOTTOM,MARGIN_LEFT,MARGIN_RIGHT}; + if (node_patch9) + node_patch9->set_patch_margin(m[edited_margin],prev_margin); + if (obj_styleBox.is_valid()) + obj_styleBox->set_margin_size(m[edited_margin],prev_margin); + edited_margin = -1; + } else { + apply_rect(rect_prev); + rect=rect_prev; + edit_draw->update(); + drag_index = -1; + } } - - } else if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) { - - zoom->set_val( zoom->get_val()/0.9 ); - } else if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) { - - zoom->set_val( zoom->get_val()*0.9); } - } else if (p_input.type==InputEvent::MOUSE_MOTION) { const InputEventMouseMotion &mm=p_input.mouse_motion; @@ -243,67 +401,89 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input) } else if (drag) { - Vector2 new_pos = mtx.affine_inverse().xform(Vector2(mm.x,mm.y)); - new_pos = snap_point(new_pos); - - if (creating) { - rect = Rect2(drag_from,Size2()); - rect.expand_to(new_pos); - apply_rect(rect); - edit_draw->update(); - return; - } - - switch(drag_index) { - case 0: { - Vector2 p=rect_prev.pos+rect_prev.size; - rect = Rect2(p,Size2()); - rect.expand_to(new_pos); - apply_rect(rect); - } break; - case 1: { - Vector2 p=rect_prev.pos+Vector2(0,rect_prev.size.y); - rect = Rect2(p,Size2(rect_prev.size.x,0)); - rect.expand_to(new_pos); - apply_rect(rect); - } break; - case 2: { - Vector2 p=rect_prev.pos+Vector2(0,rect_prev.size.y); - rect = Rect2(p,Size2()); - rect.expand_to(new_pos); - apply_rect(rect); - } break; - case 3: { - Vector2 p=rect_prev.pos; - rect = Rect2(p,Size2(0,rect_prev.size.y)); - rect.expand_to(new_pos); - apply_rect(rect); - } break; - case 4: { - Vector2 p=rect_prev.pos; - rect = Rect2(p,Size2()); - rect.expand_to(new_pos); - apply_rect(rect); - } break; - case 5: { - Vector2 p=rect_prev.pos; - rect = Rect2(p,Size2(rect_prev.size.x,0)); - rect.expand_to(new_pos); - apply_rect(rect); - } break; - case 6: { - Vector2 p=rect_prev.pos+Vector2(rect_prev.size.x,0); - rect = Rect2(p,Size2()); - rect.expand_to(new_pos); - apply_rect(rect); - } break; - case 7: { - Vector2 p=rect_prev.pos+Vector2(rect_prev.size.x,0); - rect = Rect2(p,Size2(0,rect_prev.size.y)); + if (edited_margin >= 0) { + float new_margin; + if (edited_margin == 0) + new_margin = prev_margin + (mm.y-drag_from.y) / draw_zoom; + else if (edited_margin == 1) + new_margin = prev_margin - (mm.y-drag_from.y) / draw_zoom; + else if (edited_margin == 2) + new_margin = prev_margin + (mm.x-drag_from.x) / draw_zoom; + else if (edited_margin == 3) + new_margin = prev_margin - (mm.x-drag_from.x) / draw_zoom; + if (new_margin < 0) + new_margin = 0; + static Margin m[4] = {MARGIN_TOP,MARGIN_BOTTOM,MARGIN_LEFT,MARGIN_RIGHT}; + if (node_patch9) + node_patch9->set_patch_margin(m[edited_margin],new_margin); + if (obj_styleBox.is_valid()) + obj_styleBox->set_margin_size(m[edited_margin],new_margin); + } else { + Vector2 new_pos = mtx.affine_inverse().xform(Vector2(mm.x,mm.y)); + if (snap_mode == SNAP_PIXEL) + new_pos = new_pos.snapped(Vector2(1,1)); + else if (snap_mode == SNAP_GRID) + new_pos=snap_point(new_pos); + + if (creating) { + rect = Rect2(drag_from,Size2()); rect.expand_to(new_pos); apply_rect(rect); - } break; + edit_draw->update(); + return; + } + switch(drag_index) { + case 0: { + Vector2 p=rect_prev.pos+rect_prev.size; + rect = Rect2(p,Size2()); + rect.expand_to(new_pos); + apply_rect(rect); + } break; + case 1: { + Vector2 p=rect_prev.pos+Vector2(0,rect_prev.size.y); + rect = Rect2(p,Size2(rect_prev.size.x,0)); + rect.expand_to(new_pos); + apply_rect(rect); + } break; + case 2: { + Vector2 p=rect_prev.pos+Vector2(0,rect_prev.size.y); + rect = Rect2(p,Size2()); + rect.expand_to(new_pos); + apply_rect(rect); + } break; + case 3: { + Vector2 p=rect_prev.pos; + rect = Rect2(p,Size2(0,rect_prev.size.y)); + rect.expand_to(new_pos); + apply_rect(rect); + } break; + case 4: { + Vector2 p=rect_prev.pos; + rect = Rect2(p,Size2()); + rect.expand_to(new_pos); + apply_rect(rect); + } break; + case 5: { + Vector2 p=rect_prev.pos; + rect = Rect2(p,Size2(rect_prev.size.x,0)); + rect.expand_to(new_pos); + apply_rect(rect); + } break; + case 6: { + Vector2 p=rect_prev.pos+Vector2(rect_prev.size.x,0); + rect = Rect2(p,Size2()); + rect.expand_to(new_pos); + apply_rect(rect); + } break; + case 7: { + Vector2 p=rect_prev.pos+Vector2(rect_prev.size.x,0); + rect = Rect2(p,Size2(0,rect_prev.size.y)); + rect.expand_to(new_pos); + apply_rect(rect); + } break; + + } } edit_draw->update(); } @@ -318,19 +498,21 @@ void TextureRegionEditor::_scroll_changed(float) draw_ofs.x=hscroll->get_val(); draw_ofs.y=vscroll->get_val(); - draw_zoom=zoom->get_val(); - print_line("_scroll_changed"); edit_draw->update(); } -void TextureRegionEditor::_set_use_snap(bool p_use) +void TextureRegionEditor::_set_snap_mode(int p_mode) { - use_snap=p_use; -} + snap_mode_button->get_popup()->set_item_checked(snap_mode,false); + snap_mode = p_mode; + snap_mode_button->set_text(snap_mode_button->get_popup()->get_item_text(p_mode)); + snap_mode_button->get_popup()->set_item_checked(snap_mode,true); + + if (snap_mode == SNAP_GRID) + hb_grid->show(); + else + hb_grid->hide(); -void TextureRegionEditor::_set_show_grid(bool p_show) -{ - snap_show_grid=p_show; edit_draw->update(); } @@ -358,42 +540,59 @@ void TextureRegionEditor::_set_snap_step_y(float p_val) edit_draw->update(); } -void TextureRegionEditor::apply_rect(const Rect2& rect){ +void TextureRegionEditor::_set_snap_sep_x(float p_val) +{ + snap_separation.x = p_val; + edit_draw->update(); +} - if(this->editing_region == REGION_TEXTURE_REGION) { - if(node_sprite) - node_sprite->set_region_rect(rect); - else if(node_patch9) - node_patch9->set_region_rect(rect); - else if(obj_styleBox) - obj_styleBox->set_region_rect(rect); - else if(atlas_tex) - atlas_tex->set_region(rect); +void TextureRegionEditor::_set_snap_sep_y(float p_val) +{ + snap_separation.y = p_val; + edit_draw->update(); +} + +void TextureRegionEditor::_zoom_in() +{ + if (draw_zoom < 8) { + draw_zoom *= 2; + edit_draw->update(); } - else if(this->editing_region == REGION_PATCH_MARGIN) { - if(node_patch9) { - node_patch9->set_patch_margin(MARGIN_LEFT, rect.pos.x - tex_region.pos.x); - node_patch9->set_patch_margin(MARGIN_RIGHT, tex_region.pos.x+tex_region.size.width-(rect.pos.x+rect.size.width)); - node_patch9->set_patch_margin(MARGIN_TOP, rect.pos.y - tex_region.pos.y); - node_patch9->set_patch_margin(MARGIN_BOTTOM, tex_region.pos.y+tex_region.size.height-(rect.pos.y+rect.size.height)); - } - else if(obj_styleBox) { - obj_styleBox->set_margin_size(MARGIN_LEFT, rect.pos.x - tex_region.pos.x); - obj_styleBox->set_margin_size(MARGIN_RIGHT, tex_region.pos.x+tex_region.size.width-(rect.pos.x+rect.size.width)); - obj_styleBox->set_margin_size(MARGIN_TOP, rect.pos.y - tex_region.pos.y); - obj_styleBox->set_margin_size(MARGIN_BOTTOM, tex_region.pos.y+tex_region.size.height-(rect.pos.y+rect.size.height)); - } +} + +void TextureRegionEditor::_zoom_reset() +{ + if (draw_zoom == 1) return; + draw_zoom = 1; + edit_draw->update(); +} + +void TextureRegionEditor::_zoom_out() +{ + if (draw_zoom > 0.25) { + draw_zoom /= 2; + edit_draw->update(); } } +void TextureRegionEditor::apply_rect(const Rect2& rect){ + if(node_sprite) + node_sprite->set_region_rect(rect); + else if(node_patch9) + node_patch9->set_region_rect(rect); + else if(obj_styleBox.is_valid()) + obj_styleBox->set_region_rect(rect); + else if(atlas_tex.is_valid()) + atlas_tex->set_region(rect); +} + void TextureRegionEditor::_notification(int p_what) { switch(p_what) { case NOTIFICATION_READY: { - region_button->set_icon( get_icon("RegionEdit","EditorIcons")); - margin_button->set_icon( get_icon("Patch9Frame", "EditorIcons")); - b_snap_grid->set_icon( get_icon("Grid", "EditorIcons")); - b_snap_enable->set_icon( get_icon("Snap", "EditorIcons")); + zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons")); + zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons")); + zoom_in->set_icon(get_icon("ZoomMore", "EditorIcons")); icon_zoom->set_texture( get_icon("Zoom", "EditorIcons")); } break; } @@ -401,149 +600,165 @@ void TextureRegionEditor::_notification(int p_what) void TextureRegionEditor::_node_removed(Object *p_obj) { - if(p_obj == node_sprite || p_obj == node_patch9 || p_obj == obj_styleBox || p_obj == atlas_tex) { - node_patch9 = NULL; - node_sprite = NULL; - obj_styleBox = NULL; - atlas_tex = NULL; + if(p_obj == node_sprite || p_obj == node_patch9 || p_obj == obj_styleBox.ptr() || p_obj == atlas_tex.ptr()) { + node_patch9 = NULL; + node_sprite = NULL; + obj_styleBox = Ref<StyleBox>(NULL); + atlas_tex = Ref<AtlasTexture>(NULL); hide(); } } void TextureRegionEditor::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_edit_node"),&TextureRegionEditor::_edit_node); ObjectTypeDB::bind_method(_MD("_edit_region"),&TextureRegionEditor::_edit_region); - ObjectTypeDB::bind_method(_MD("_edit_margin"),&TextureRegionEditor::_edit_margin); ObjectTypeDB::bind_method(_MD("_region_draw"),&TextureRegionEditor::_region_draw); ObjectTypeDB::bind_method(_MD("_region_input"),&TextureRegionEditor::_region_input); ObjectTypeDB::bind_method(_MD("_scroll_changed"),&TextureRegionEditor::_scroll_changed); ObjectTypeDB::bind_method(_MD("_node_removed"),&TextureRegionEditor::_node_removed); - ObjectTypeDB::bind_method(_MD("_set_use_snap"),&TextureRegionEditor::_set_use_snap); - ObjectTypeDB::bind_method(_MD("_set_show_grid"),&TextureRegionEditor::_set_show_grid); + ObjectTypeDB::bind_method(_MD("_set_snap_mode"),&TextureRegionEditor::_set_snap_mode); ObjectTypeDB::bind_method(_MD("_set_snap_off_x"),&TextureRegionEditor::_set_snap_off_x); ObjectTypeDB::bind_method(_MD("_set_snap_off_y"),&TextureRegionEditor::_set_snap_off_y); ObjectTypeDB::bind_method(_MD("_set_snap_step_x"),&TextureRegionEditor::_set_snap_step_x); ObjectTypeDB::bind_method(_MD("_set_snap_step_y"),&TextureRegionEditor::_set_snap_step_y); + ObjectTypeDB::bind_method(_MD("_set_snap_sep_x"),&TextureRegionEditor::_set_snap_sep_x); + ObjectTypeDB::bind_method(_MD("_set_snap_sep_y"),&TextureRegionEditor::_set_snap_sep_y); + ObjectTypeDB::bind_method(_MD("_zoom_in"),&TextureRegionEditor::_zoom_in); + ObjectTypeDB::bind_method(_MD("_zoom_reset"),&TextureRegionEditor::_zoom_reset); + ObjectTypeDB::bind_method(_MD("_zoom_out"),&TextureRegionEditor::_zoom_out); } void TextureRegionEditor::edit(Object *p_obj) { + if (node_sprite && node_sprite->is_connected("texture_changed",this,"_edit_region")) + node_sprite->disconnect("texture_changed",this,"_edit_region"); + if (node_patch9 && node_patch9->is_connected("texture_changed",this,"_edit_region")) + node_patch9->disconnect("texture_changed",this,"_edit_region"); + if (obj_styleBox.is_valid() && obj_styleBox->is_connected("texture_changed",this,"_edit_region")) + obj_styleBox->disconnect("texture_changed",this,"_edit_region"); + if (atlas_tex.is_valid() && atlas_tex->is_connected("atlas_changed",this,"_edit_region")) + atlas_tex->disconnect("atlas_changed",this,"_edit_region"); if (p_obj) { - margin_button->hide(); - node_type = p_obj->get_type(); - if(node_type == "Sprite"){ - node_sprite = p_obj->cast_to<Sprite>(); - node_patch9 = NULL; - obj_styleBox = NULL; - atlas_tex = NULL; - } - else if(node_type == "AtlasTexture") { - atlas_tex = p_obj->cast_to<AtlasTexture>(); - node_sprite = NULL; - node_patch9 = NULL; - obj_styleBox = NULL; - } - else if(node_type == "Patch9Frame") { - node_patch9 = p_obj->cast_to<Patch9Frame>(); - node_sprite = NULL; - obj_styleBox = NULL; - atlas_tex = NULL; - margin_button->show(); - } - else if(node_type == "StyleBoxTexture") { - obj_styleBox = p_obj->cast_to<StyleBoxTexture>(); - node_sprite = NULL; - node_patch9 = NULL; - atlas_tex = NULL; - margin_button->show(); + node_sprite = p_obj->cast_to<Sprite>(); + node_patch9 = p_obj->cast_to<Patch9Frame>(); + if (p_obj->cast_to<StyleBoxTexture>()) + obj_styleBox = Ref<StyleBoxTexture>(p_obj->cast_to<StyleBoxTexture>()); + if (p_obj->cast_to<AtlasTexture>()) { + atlas_tex = Ref<AtlasTexture>(p_obj->cast_to<AtlasTexture>()); + atlas_tex->connect("atlas_changed",this,"_edit_region"); + } else { + p_obj->connect("texture_changed",this,"_edit_region"); } p_obj->connect("exit_tree",this,"_node_removed",varray(p_obj),CONNECT_ONESHOT); + _edit_region(); } else { if(node_sprite) node_sprite->disconnect("exit_tree",this,"_node_removed"); - else if(atlas_tex) - atlas_tex->disconnect("exit_tree",this,"_node_removed"); else if(node_patch9) node_patch9->disconnect("exit_tree",this,"_node_removed"); - else if(obj_styleBox) + else if(obj_styleBox.is_valid()) obj_styleBox->disconnect("exit_tree",this,"_node_removed"); - node_sprite = NULL; - node_patch9 = NULL; - obj_styleBox = NULL; - atlas_tex = NULL; + else if(atlas_tex.is_valid()) + atlas_tex->disconnect("exit_tree",this,"_node_removed"); + + node_sprite = NULL; + node_patch9 = NULL; + obj_styleBox = Ref<StyleBoxTexture>(NULL); + atlas_tex = Ref<AtlasTexture>(NULL); } + edit_draw->update(); } void TextureRegionEditor::_edit_region() { - this->_edit_node(REGION_TEXTURE_REGION); - dlg_editor->set_title(TTR("Texture Region Editor")); -} - -void TextureRegionEditor::_edit_margin() -{ - this->_edit_node(REGION_PATCH_MARGIN); - dlg_editor->set_title(TTR("Scale Region Editor")); -} - -void TextureRegionEditor::_edit_node(int region) -{ Ref<Texture> texture = NULL; - if(node_type == "Sprite" && node_sprite ) + if(node_sprite ) texture = node_sprite->get_texture(); - else if(node_type == "Patch9Frame" && node_patch9 ) + else if(node_patch9 ) texture = node_patch9->get_texture(); - else if(node_type == "StyleBoxTexture" && obj_styleBox) + else if(obj_styleBox.is_valid()) texture = obj_styleBox->get_texture(); - else if(node_type == "AtlasTexture" && atlas_tex) + else if(atlas_tex.is_valid()) texture = atlas_tex->get_atlas(); if (texture.is_null()) { - error->set_text(TTR("No texture in this node.\nSet a texture to be able to edit region.")); - error->popup_centered_minsize(); return; } - if(node_type == "Sprite" && node_sprite ) - tex_region = node_sprite->get_region_rect(); - else if(node_type == "Patch9Frame" && node_patch9 ) - tex_region = node_patch9->get_region_rect(); - else if(node_type == "StyleBoxTexture" && obj_styleBox) - tex_region = obj_styleBox->get_region_rect(); - else if(node_type == "AtlasTexture" && atlas_tex) - tex_region = atlas_tex->get_region(); - rect = tex_region; - - if(region == REGION_PATCH_MARGIN) { - if(node_patch9){ - Patch9Frame *node = node_patch9; - rect.pos += Point2(node->get_patch_margin(MARGIN_LEFT),node->get_patch_margin(MARGIN_TOP)); - rect.size -= Size2(node->get_patch_margin(MARGIN_RIGHT)+node->get_patch_margin(MARGIN_LEFT), node->get_patch_margin(MARGIN_BOTTOM)+node->get_patch_margin(MARGIN_TOP)); - } - else if(obj_styleBox) { - StyleBoxTexture * node = obj_styleBox; - rect.pos += Point2(node->get_margin_size(MARGIN_LEFT),node->get_margin_size(MARGIN_TOP)); - rect.size -= Size2(node->get_margin_size(MARGIN_RIGHT)+node->get_margin_size(MARGIN_LEFT), node->get_margin_size(MARGIN_BOTTOM)+node->get_margin_size(MARGIN_TOP)); + autoslice_cache.clear(); + Image i; + if (i.load(texture->get_path()) == OK) { + BitMap bm; + bm.create_from_image_alpha(i); + for (int y = 0; y < i.get_height(); y++) { + for (int x = 0; x < i.get_width(); x++) { + if (bm.get_bit(Point2(x,y))) { + bool found = false; + for (List<Rect2>::Element *E = autoslice_cache.front(); E; E=E->next()) { + Rect2 grown = E->get().grow(1.5); + if (grown.has_point(Point2(x,y))) { + E->get().expand_to(Point2(x,y)); + E->get().expand_to(Point2(x+1,y+1)); + x = E->get().pos.x+E->get().size.x-1; + bool merged = true; + while (merged) { + merged = false; + for (List<Rect2>::Element *F = autoslice_cache.front(); F; F=F->next()) { + if (F==E) + continue; + if (E->get().grow(1).intersects(F->get())) { + E->get().expand_to(F->get().pos); + E->get().expand_to(F->get().pos+F->get().size); + F=F->prev(); + autoslice_cache.erase(F->next()); + merged = true; + } + } + } + found = true; + break; + } + } + if (!found) { + Rect2 new_rect(x,y,1,1); + autoslice_cache.push_back(new_rect); + } + } + } } } - dlg_editor->popup_centered_ratio(0.85); - dlg_editor->get_ok()->release_focus(); - editing_region = region; + if(node_sprite ) + rect = node_sprite->get_region_rect(); + else if(node_patch9 ) + rect = node_patch9->get_region_rect(); + else if(obj_styleBox.is_valid()) + rect = obj_styleBox->get_region_rect(); + else if (atlas_tex.is_valid()) + rect = atlas_tex->get_region(); + + edit_draw->update(); } -inline float _snap_scalar(float p_offset, float p_step, float p_target) { - return p_step != 0 ? Math::stepify(p_target - p_offset, p_step) + p_offset : p_target; +inline float _snap_scalar(float p_offset, float p_step, float separation, float p_target) { + if (p_step != 0) { + float a = Math::stepify(p_target - p_offset, p_step+separation) + p_offset; + float b = a; + if (p_target >= 0) + b -= separation; + else + b += p_step; + return (Math::abs(p_target-a) < Math::abs(p_target-b)) ? a : b; + } + return p_target; } Vector2 TextureRegionEditor::snap_point(Vector2 p_target) const { - if (use_snap) { - p_target.x = _snap_scalar(snap_offset.x, snap_step.x, p_target.x); - p_target.y = _snap_scalar(snap_offset.y, snap_step.y, p_target.y); + if (snap_mode == SNAP_GRID) { + p_target.x = _snap_scalar(snap_offset.x, snap_step.x, snap_separation.x, p_target.x); + p_target.y = _snap_scalar(snap_offset.y, snap_step.y, snap_separation.y, p_target.y); } - p_target = p_target.snapped(Size2(1, 1)); return p_target; } @@ -552,56 +767,42 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor) { node_sprite = NULL; node_patch9 = NULL; - atlas_tex = NULL; + obj_styleBox = Ref<StyleBoxTexture>(NULL); + atlas_tex = Ref<AtlasTexture>(NULL); editor=p_editor; undo_redo = editor->get_undo_redo(); snap_step=Vector2(10,10); - use_snap=false; - snap_show_grid=false; + snap_separation = Vector2(0,0); + edited_margin = -1; + drag_index = -1; drag=false; - add_child( memnew( VSeparator )); - region_button = memnew( ToolButton ); - add_child(region_button); - region_button->set_tooltip(TTR("Texture Region Editor")); - region_button->connect("pressed",this,"_edit_region"); - - margin_button = memnew( ToolButton ); - add_child(margin_button); - margin_button->set_tooltip(TTR("Scale Region Editor")); - margin_button->connect("pressed",this,"_edit_margin"); - - dlg_editor = memnew( AcceptDialog ); - add_child(dlg_editor); - dlg_editor->set_self_opacity(0.9); - VBoxContainer *main_vb = memnew( VBoxContainer ); - dlg_editor->add_child(main_vb); - dlg_editor->set_child_rect(main_vb); + add_child(main_vb); + main_vb->set_area_as_parent_rect(0); HBoxContainer *hb_tools = memnew( HBoxContainer ); main_vb->add_child(hb_tools); - b_snap_enable = memnew( ToolButton ); - hb_tools->add_child(b_snap_enable); - b_snap_enable->set_text(TTR("Snap")); - b_snap_enable->set_focus_mode(FOCUS_NONE); - b_snap_enable->set_toggle_mode(true); - b_snap_enable->set_pressed(use_snap); - b_snap_enable->set_tooltip(TTR("Enable Snap")); - b_snap_enable->connect("toggled",this,"_set_use_snap"); - - b_snap_grid = memnew( ToolButton ); - hb_tools->add_child(b_snap_grid); - b_snap_grid->set_text(TTR("Grid")); - b_snap_grid->set_focus_mode(FOCUS_NONE); - b_snap_grid->set_toggle_mode(true); - b_snap_grid->set_pressed(snap_show_grid); - b_snap_grid->set_tooltip(TTR("Show Grid")); - b_snap_grid->connect("toggled",this,"_set_show_grid"); - - hb_tools->add_child( memnew( VSeparator )); - hb_tools->add_child( memnew( Label(TTR("Grid Offset:")) ) ); + hb_tools->add_child(memnew( Label(TTR("Snap Mode:")) )); + + snap_mode_button = memnew( MenuButton ); + hb_tools->add_child(snap_mode_button); + snap_mode_button->set_text(TTR("<None>")); + PopupMenu *p = snap_mode_button->get_popup(); + p->add_item(TTR("<None>"),0); + p->add_item(TTR("Pixel Snap"),1); + p->add_item(TTR("Grid Snap"),2); + p->add_item(TTR("Auto Slice"),3); + for (int i = 0; i < 4; i++) + p->set_item_as_checkable(i,true); + p->set_item_checked(0,true); + p->connect("item_pressed", this, "_set_snap_mode"); + hb_grid = memnew( HBoxContainer ); + hb_tools->add_child(hb_grid); + hb_grid->add_child( memnew( VSeparator )); + + hb_grid->add_child( memnew( Label(TTR("Offset:")) ) ); sb_off_x = memnew( SpinBox ); sb_off_x->set_min(-256); @@ -610,7 +811,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor) sb_off_x->set_val(snap_offset.x); sb_off_x->set_suffix("px"); sb_off_x->connect("value_changed", this, "_set_snap_off_x"); - hb_tools->add_child(sb_off_x); + hb_grid->add_child(sb_off_x); sb_off_y = memnew( SpinBox ); sb_off_y->set_min(-256); @@ -619,10 +820,10 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor) sb_off_y->set_val(snap_offset.y); sb_off_y->set_suffix("px"); sb_off_y->connect("value_changed", this, "_set_snap_off_y"); - hb_tools->add_child(sb_off_y); + hb_grid->add_child(sb_off_y); - hb_tools->add_child( memnew( VSeparator )); - hb_tools->add_child( memnew( Label(TTR("Grid Step:")) ) ); + hb_grid->add_child( memnew( VSeparator )); + hb_grid->add_child( memnew( Label(TTR("Step:")) ) ); sb_step_x = memnew( SpinBox ); sb_step_x->set_min(-256); @@ -631,7 +832,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor) sb_step_x->set_val(snap_step.x); sb_step_x->set_suffix("px"); sb_step_x->connect("value_changed", this, "_set_snap_step_x"); - hb_tools->add_child(sb_step_x); + hb_grid->add_child(sb_step_x); sb_step_y = memnew( SpinBox ); sb_step_y->set_min(-256); @@ -640,7 +841,30 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor) sb_step_y->set_val(snap_step.y); sb_step_y->set_suffix("px"); sb_step_y->connect("value_changed", this, "_set_snap_step_y"); - hb_tools->add_child(sb_step_y); + hb_grid->add_child(sb_step_y); + + hb_grid->add_child( memnew( VSeparator )); + hb_grid->add_child( memnew( Label(TTR("Separation:")) ) ); + + sb_sep_x = memnew( SpinBox ); + sb_sep_x->set_min(0); + sb_sep_x->set_max(256); + sb_sep_x->set_step(1); + sb_sep_x->set_val(snap_separation.x); + sb_sep_x->set_suffix("px"); + sb_sep_x->connect("value_changed", this, "_set_snap_sep_x"); + hb_grid->add_child(sb_sep_x); + + sb_sep_y = memnew( SpinBox ); + sb_sep_y->set_min(0); + sb_sep_y->set_max(256); + sb_sep_y->set_step(1); + sb_sep_y->set_val(snap_separation.y); + sb_sep_y->set_suffix("px"); + sb_sep_y->connect("value_changed", this, "_set_snap_sep_y"); + hb_grid->add_child(sb_sep_y); + + hb_grid->hide(); HBoxContainer *main_hb = memnew( HBoxContainer ); main_vb->add_child(main_hb); @@ -649,25 +873,24 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor) main_hb->set_v_size_flags(SIZE_EXPAND_FILL); edit_draw->set_h_size_flags(SIZE_EXPAND_FILL); + Control * separator = memnew( Control ); + separator->set_h_size_flags(Control::SIZE_EXPAND_FILL); + hb_tools->add_child(separator); - hb_tools->add_child( memnew( VSeparator )); icon_zoom = memnew( TextureFrame ); hb_tools->add_child(icon_zoom); - zoom = memnew( HSlider ); - zoom->set_min(0.01); - zoom->set_max(4); - zoom->set_val(1); - zoom->set_step(0.01); - hb_tools->add_child(zoom); - zoom->set_custom_minimum_size(Size2(200,0)); - zoom_value = memnew( SpinBox ); - zoom->share(zoom_value); - zoom_value->set_custom_minimum_size(Size2(50,0)); - hb_tools->add_child(zoom_value); - zoom->connect("value_changed",this,"_scroll_changed"); + zoom_out = memnew( ToolButton ); + zoom_out->connect("pressed", this, "_zoom_out"); + hb_tools->add_child(zoom_out); + zoom_reset = memnew( ToolButton ); + zoom_reset->connect("pressed", this, "_zoom_reset"); + hb_tools->add_child(zoom_reset); + zoom_in = memnew( ToolButton ); + zoom_in->connect("pressed", this, "_zoom_in"); + hb_tools->add_child(zoom_in); vscroll = memnew( VScrollBar); main_hb->add_child(vscroll); @@ -681,9 +904,6 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor) draw_zoom=1.0; updating_scroll=false; - error = memnew( AcceptDialog); - add_child(error); - } void TextureRegionEditorPlugin::edit(Object *p_node) @@ -699,10 +919,13 @@ bool TextureRegionEditorPlugin::handles(Object *p_obj) const void TextureRegionEditorPlugin::make_visible(bool p_visible) { if (p_visible) { - region_editor->show(); + region_button->show(); + if (region_button->is_pressed()) + region_editor->show(); } else { - region_editor->hide(); + region_button->hide(); region_editor->edit(NULL); + region_editor->hide(); } } @@ -710,11 +933,11 @@ void TextureRegionEditorPlugin::make_visible(bool p_visible) Dictionary TextureRegionEditorPlugin::get_state() const { Dictionary state; - state["zoom"]=region_editor->zoom->get_val(); + state["zoom"]=region_editor->draw_zoom; 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; + state["snap_separation"]=region_editor->snap_separation; + state["snap_mode"]=region_editor->snap_mode; return state; } @@ -722,7 +945,7 @@ void TextureRegionEditorPlugin::set_state(const Dictionary& p_state){ Dictionary state=p_state; if (state.has("zoom")) { - region_editor->zoom->set_val(p_state["zoom"]); + region_editor->draw_zoom = p_state["zoom"]; } if (state.has("snap_step")) { @@ -739,22 +962,28 @@ void TextureRegionEditorPlugin::set_state(const Dictionary& p_state){ 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_separation")) { + Vector2 sep = state["snap_separation"]; + region_editor->sb_sep_x->set_val(sep.x); + region_editor->sb_sep_y->set_val(sep.y); + region_editor->snap_separation = sep; } - 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"]); + if (state.has("snap_mode")) { + region_editor->_set_snap_mode(state["snap_mode"]); } + } TextureRegionEditorPlugin::TextureRegionEditorPlugin(EditorNode *p_node) { editor = p_node; - region_editor= memnew ( TextureRegionEditor(p_node) ); - CanvasItemEditor::get_singleton()->add_control_to_menu_panel(region_editor); + region_editor = memnew ( TextureRegionEditor(p_node) ); + + region_button = p_node->add_bottom_panel_item(TTR("Texture Region"), region_editor); + region_button->set_tooltip(TTR("Texture Region Editor")); + region_editor->set_custom_minimum_size(Size2(0,200)); region_editor->hide(); + region_button->hide(); } diff --git a/tools/editor/plugins/texture_region_editor_plugin.h b/tools/editor/plugins/texture_region_editor_plugin.h index 1e4888b06d..3658a38f11 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.h +++ b/tools/editor/plugins/texture_region_editor_plugin.h @@ -40,69 +40,73 @@ #include "scene/resources/style_box.h" #include "scene/resources/texture.h" -class TextureRegionEditor : public HBoxContainer { +class TextureRegionEditor : public Control { - OBJ_TYPE(TextureRegionEditor, HBoxContainer ); - enum RegionType { - REGION_TEXTURE_REGION, - REGION_PATCH_MARGIN + OBJ_TYPE(TextureRegionEditor, Control ); + + enum SnapMode { + SNAP_NONE, + SNAP_PIXEL, + SNAP_GRID, + SNAP_AUTOSLICE }; friend class TextureRegionEditorPlugin; - ToolButton *region_button; - ToolButton *margin_button; - ToolButton *b_snap_enable; - ToolButton *b_snap_grid; + MenuButton *snap_mode_button; TextureFrame *icon_zoom; - HSlider *zoom; - SpinBox *zoom_value; + ToolButton *zoom_in; + ToolButton *zoom_reset; + ToolButton *zoom_out; + HBoxContainer * hb_grid; //For showing/hiding the grid controls when changing the SnapMode SpinBox *sb_step_y; SpinBox *sb_step_x; SpinBox *sb_off_y; SpinBox *sb_off_x; + SpinBox *sb_sep_y; + SpinBox *sb_sep_x; Control *edit_draw; VScrollBar *vscroll; HScrollBar *hscroll; EditorNode *editor; - AcceptDialog *dlg_editor; UndoRedo* undo_redo; Vector2 draw_ofs; float draw_zoom; bool updating_scroll; - bool use_snap; - bool snap_show_grid; + int snap_mode; Vector2 snap_offset; Vector2 snap_step; + Vector2 snap_separation; - - String node_type; Patch9Frame *node_patch9; Sprite *node_sprite; - StyleBoxTexture *obj_styleBox; - AtlasTexture *atlas_tex; + Ref<StyleBoxTexture> obj_styleBox; + Ref<AtlasTexture> atlas_tex; - int editing_region; Rect2 rect; Rect2 rect_prev; - Rect2 tex_region; + float prev_margin; + int edited_margin; + List<Rect2> autoslice_cache; bool drag; bool creating; Vector2 drag_from; int drag_index; - AcceptDialog *error; - - void _set_use_snap(bool p_use); - void _set_show_grid(bool p_show); + void _set_snap_mode(int p_mode); void _set_snap_off_x(float p_val); void _set_snap_off_y(float p_val); void _set_snap_step_x(float p_val); void _set_snap_step_y(float p_val); + void _set_snap_sep_x(float p_val); + void _set_snap_sep_y(float p_val); + void _zoom_in(); + void _zoom_reset(); + void _zoom_out(); void apply_rect(const Rect2& rect); protected: @@ -114,9 +118,7 @@ protected: public: - void _edit_node(int tex_region); void _edit_region(); - void _edit_margin(); void _region_draw(); void _region_input(const InputEvent &p_input); void _scroll_changed(float); @@ -130,11 +132,12 @@ class TextureRegionEditorPlugin : public EditorPlugin { OBJ_TYPE( TextureRegionEditorPlugin, EditorPlugin ); + Button *region_button; TextureRegionEditor *region_editor; EditorNode *editor; public: - virtual String get_name() const { return "SpriteRegion"; } + virtual String get_name() const { return "TextureRegion"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_node); virtual bool handles(Object *p_node) const; diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index d5f85d3333..d686c37d1a 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -223,7 +223,7 @@ void TileMapEditor::_update_palette() { String name; if (tileset->tile_get_name(E->get())!="") { - name = tileset->tile_get_name(E->get()); + name = itos(E->get())+" - "+tileset->tile_get_name(E->get()); } else { name = "#"+itos(E->get()); } @@ -412,6 +412,24 @@ void TileMapEditor::_draw_cell(int p_cell, const Point2i& p_point, bool p_flip_h if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) { rect.pos+=tile_ofs; + } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_BOTTOM_LEFT) { + Size2 cell_size = node->get_cell_size(); + + rect.pos+=tile_ofs; + + if(p_transpose) + { + if(p_flip_h) + rect.pos.x-=cell_size.x; + else + rect.pos.x+=cell_size.x; + } else { + if(p_flip_v) + rect.pos.y-=cell_size.y; + else + rect.pos.y+=cell_size.y; + } + } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) { rect.pos+=node->get_cell_size()/2; Vector2 s = r.size; diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp index a2c7147bf3..39a15189e7 100644 --- a/tools/editor/plugins/tile_set_editor_plugin.cpp +++ b/tools/editor/plugins/tile_set_editor_plugin.cpp @@ -73,24 +73,24 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me p_library->tile_set_name(id,mi->get_name()); } - - p_library->tile_set_texture(id,texture); p_library->tile_set_material(id,material); Vector2 phys_offset; + Size2 s; - if (mi->is_centered()) { - Size2 s; - if (mi->is_region()) { - s=mi->get_region_rect().size; - } else { - s=texture->get_size(); - } - phys_offset+=-s/2; - } if (mi->is_region()) { + s=mi->get_region_rect().size; p_library->tile_set_region(id,mi->get_region_rect()); + } else { + const int frame = mi->get_frame(); + const int hframes = mi->get_hframes(); + s=texture->get_size()/Size2(hframes,mi->get_vframes()); + p_library->tile_set_region(id,Rect2(Vector2(frame%hframes,frame/hframes)*s,s)); + } + + if (mi->is_centered()) { + phys_offset+=-s/2; } Vector<Ref<Shape2D> >collisions; diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index 3f82199fc3..103962716b 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -431,7 +431,6 @@ void ProjectExportDialog::_validate_platform() { void ProjectExportDialog::_export_mode_changed(int p_idx) { - bool do_all = p_idx==0; if (EditorImportExport::get_singleton()->get_export_filter()==p_idx) return; EditorImportExport::get_singleton()->set_export_filter(EditorImportExport::ExportFilter(p_idx)); diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index d8814fd50e..52c8ca4d6c 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -46,20 +46,33 @@ #include "io/resource_saver.h" #include "editor_themes.h" - +#include "editor_initialize_ssl.h" #include "editor_scale.h" +#include "io/zip_io.h" + class NewProjectDialog : public ConfirmationDialog { OBJ_TYPE(NewProjectDialog,ConfirmationDialog); +public: - bool import_mode; + enum Mode { + MODE_NEW, + MODE_IMPORT, + MODE_INSTALL + }; +private: + + Mode mode; Label *pp,*pn; Label *error; LineEdit *project_path; LineEdit *project_name; FileDialog *fdialog; + String zip_path; + String zip_title; + AcceptDialog *dialog_error; bool _test_path() { @@ -72,7 +85,7 @@ class NewProjectDialog : public ConfirmationDialog { return false; } - if (!import_mode) { + if (mode!=MODE_IMPORT) { if (d->file_exists("engine.cfg")) { @@ -109,7 +122,7 @@ class NewProjectDialog : public ConfirmationDialog { if (lidx!=-1) { sp=sp.substr(lidx+1,sp.length()); } - if (sp=="" && import_mode ) + if (sp=="" && mode==MODE_IMPORT ) sp=TTR("Imported Project"); project_name->set_text(sp); @@ -119,7 +132,7 @@ class NewProjectDialog : public ConfirmationDialog { void _file_selected(const String& p_path) { String p = p_path; - if (import_mode) { + if (mode==MODE_IMPORT) { if (p.ends_with("engine.cfg")) { p=p.get_base_dir(); @@ -141,7 +154,7 @@ class NewProjectDialog : public ConfirmationDialog { void _browse_path() { - if (import_mode) { + if (mode==MODE_IMPORT) { fdialog->set_mode(FileDialog::MODE_OPEN_FILE); fdialog->clear_filters(); @@ -163,7 +176,7 @@ class NewProjectDialog : public ConfirmationDialog { String dir; - if (import_mode) { + if (mode==MODE_IMPORT) { dir=project_path->get_text(); @@ -179,26 +192,130 @@ class NewProjectDialog : public ConfirmationDialog { dir=d->get_current_dir(); memdelete(d); - FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"),FileAccess::WRITE); - if (!f) { - error->set_text(TTR("Couldn't create engine.cfg in project path.")); - } else { + if (mode==MODE_NEW) { + + + + + FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"),FileAccess::WRITE); + if (!f) { + error->set_text(TTR("Couldn't create engine.cfg in project path.")); + } else { + + f->store_line("; Engine configuration file."); + f->store_line("; It's best to edit using the editor UI, not directly,"); + f->store_line("; becausethe parameters that go here are not obvious."); + f->store_line("; "); + f->store_line("; Format: "); + f->store_line("; [section] ; section goes between []"); + f->store_line("; param=value ; assign values to parameters"); + f->store_line("\n"); + f->store_line("[application]"); + f->store_line("name=\""+project_name->get_text()+"\""); + f->store_line("icon=\"res://icon.png\""); + + memdelete(f); + + ResourceSaver::save(dir.plus_file("/icon.png"),get_icon("DefaultProjectIcon","EditorIcons")); + } + + } else if (mode==MODE_INSTALL) { + + + FileAccess *src_f=NULL; + zlib_filefunc_def io = zipio_create_io_from_file(&src_f); + + unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io); + if (!pkg) { + + dialog_error->set_text("Error opening package file, not in zip format."); + return; + } + + int ret = unzGoToFirstFile(pkg); + + Vector<String> failed_files; + + int idx=0; + while(ret==UNZ_OK) { + + //get filename + unz_file_info info; + char fname[16384]; + ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0); + + String path=fname; + + int depth=1; //stuff from github comes with tag + bool skip=false; + while(depth>0) { + int pp = path.find("/"); + if (pp==-1) { + skip=true; + break; + } + path=path.substr(pp+1,path.length()); + depth--; + } + + + if (skip || path==String()) { + // + } else if (path.ends_with("/")) { // a dir + + path=path.substr(0,path.length()-1); + + DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + da->make_dir(dir.plus_file(path)); + memdelete(da); + + } else { + + Vector<uint8_t> data; + data.resize(info.uncompressed_size); + + //read + unzOpenCurrentFile(pkg); + unzReadCurrentFile(pkg,data.ptr(),data.size()); + unzCloseCurrentFile(pkg); + + FileAccess *f=FileAccess::open(dir.plus_file(path),FileAccess::WRITE); + + if (f) { + f->store_buffer(data.ptr(),data.size()); + memdelete(f); + } else { + failed_files.push_back(path); + } + + + } + + idx++; + ret = unzGoToNextFile(pkg); + } + + unzClose(pkg); + + if (failed_files.size()) { + String msg=TTR("The following files failed extraction from package:")+"\n\n"; + for(int i=0;i<failed_files.size();i++) { + + if (i>15) { + msg+="\nAnd "+itos(failed_files.size()-i)+" more files."; + break; + } + msg+=failed_files[i]+"\n"; + } + + dialog_error->set_text(msg); + dialog_error->popup_centered_minsize(); + + } else { + dialog_error->set_text(TTR("Package Installed Successfully!")); + dialog_error->popup_centered_minsize(); + } - f->store_line("; Engine configuration file."); - f->store_line("; It's best to edit using the editor UI, not directly,"); - f->store_line("; becausethe parameters that go here are not obvious."); - f->store_line("; "); - f->store_line("; Format: "); - f->store_line("; [section] ; section goes between []"); - f->store_line("; param=value ; assign values to parameters"); - f->store_line("\n"); - f->store_line("[application]"); - f->store_line("name=\""+project_name->get_text()+"\""); - f->store_line("icon=\"res://icon.png\""); - - memdelete(f); - - ResourceSaver::save(dir.plus_file("/icon.png"),get_icon("DefaultProjectIcon","EditorIcons")); } @@ -233,10 +350,16 @@ protected: public: + void set_zip_path(const String& p_path) { + zip_path=p_path; + } + void set_zip_title(const String& p_title) { + zip_title=p_title; + } - void set_import_mode(bool p_import ) { + void set_mode(Mode p_mode) { - import_mode=p_import; + mode=p_mode; } void show_dialog() { @@ -245,7 +368,7 @@ public: project_path->clear(); project_name->clear(); - if (import_mode) { + if (mode==MODE_IMPORT) { set_title(TTR("Import Existing Project")); get_ok()->set_text(TTR("Import")); pp->set_text(TTR("Project Path (Must Exist):")); @@ -253,9 +376,10 @@ public: pn->hide(); project_name->hide(); - popup_centered(Size2(500,125)); + popup_centered(Size2(500,125)*EDSCALE); + + } else if (mode==MODE_NEW){ - } else { set_title(TTR("Create New Project")); get_ok()->set_text(TTR("Create")); pp->set_text(TTR("Project Path:")); @@ -263,7 +387,16 @@ public: pn->show(); project_name->show(); - popup_centered(Size2(500,145)); + popup_centered(Size2(500,145)*EDSCALE); + } else if (mode==MODE_INSTALL){ + + set_title(TTR("Install Project:")+" "+zip_title); + get_ok()->set_text(TTR("Install")); + pp->set_text(TTR("Project Path:")); + pn->hide(); + project_name->hide(); + + popup_centered(Size2(500,125)*EDSCALE); } @@ -329,7 +462,10 @@ public: fdialog->connect("dir_selected", this,"_path_selected"); fdialog->connect("file_selected", this,"_file_selected"); set_hide_on_ok(false); - import_mode=false; + mode=MODE_NEW; + + dialog_error = memnew( AcceptDialog ); + add_child(dialog_error); } @@ -616,6 +752,8 @@ void ProjectManager::_load_recent_projects() { run_btn->set_disabled(selected_list.size()<1 || (selected_list.size()==1 && single_selected_main=="")); EditorSettings::get_singleton()->save(); + + tabs->set_current_tab(0); } void ProjectManager::_open_project_confirm() { @@ -755,14 +893,14 @@ void ProjectManager::_scan_projects() { void ProjectManager::_new_project() { - npdialog->set_import_mode(false); + npdialog->set_mode(NewProjectDialog::MODE_NEW); npdialog->show_dialog(); } void ProjectManager::_import_project() { - npdialog->set_import_mode(true); + npdialog->set_mode(NewProjectDialog::MODE_IMPORT); npdialog->show_dialog(); } @@ -800,6 +938,15 @@ void ProjectManager::_exit_dialog() { get_tree()->quit(); } + +void ProjectManager::_install_project(const String& p_zip_path,const String& p_title) { + + npdialog->set_mode(NewProjectDialog::MODE_INSTALL); + npdialog->set_zip_path(p_zip_path); + npdialog->set_zip_title(p_title); + npdialog->show_dialog(); +} + void ProjectManager::_bind_methods() { ObjectTypeDB::bind_method("_open_project",&ProjectManager::_open_project); @@ -817,19 +964,20 @@ void ProjectManager::_bind_methods() { ObjectTypeDB::bind_method("_panel_draw",&ProjectManager::_panel_draw); ObjectTypeDB::bind_method("_panel_input",&ProjectManager::_panel_input); ObjectTypeDB::bind_method("_favorite_pressed",&ProjectManager::_favorite_pressed); + ObjectTypeDB::bind_method("_install_project",&ProjectManager::_install_project); } ProjectManager::ProjectManager() { - int margin = get_constant("margin","Dialogs"); - int button_margin = get_constant("button_margin","Dialogs"); - // load settings if (!EditorSettings::get_singleton()) EditorSettings::create(); + + EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came + { int dpi_mode = EditorSettings::get_singleton()->get("global/hidpi_mode"); if (dpi_mode==0) { @@ -871,9 +1019,6 @@ ProjectManager::ProjectManager() { HBoxContainer *top_hb = memnew( HBoxContainer); vb->add_child(top_hb); - TextureFrame *logo = memnew( TextureFrame ); - logo->set_texture(theme->get_icon("LogoSmall","EditorIcons")); - //top_hb->add_child( logo ); CenterContainer *ccl = memnew( CenterContainer ); Label *l = memnew( Label ); l->set_text(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager")); @@ -981,10 +1126,10 @@ ProjectManager::ProjectManager() { if (StreamPeerSSL::is_available()) { - asset_library = memnew( EditorAssetLibrary(true) ); asset_library->set_name("Templates"); tabs->add_child(asset_library); + asset_library->connect("install_asset",this,"_install_project"); } else { WARN_PRINT("Asset Library not available, as it requires SSL to work."); } @@ -1018,8 +1163,6 @@ ProjectManager::ProjectManager() { gui_base->add_child(multi_run_ask); - - OS::get_singleton()->set_low_processor_usage_mode(true); npdialog = memnew( NewProjectDialog ); @@ -1103,6 +1246,8 @@ void ProjectListFilter::_bind_methods() { ProjectListFilter::ProjectListFilter() { + editor_initialize_certificates(); //for asset sharing + _current_filter = FILTER_NAME; filter_option = memnew(OptionButton); diff --git a/tools/editor/project_manager.h b/tools/editor/project_manager.h index 2db1bb839e..69467f50e7 100644 --- a/tools/editor/project_manager.h +++ b/tools/editor/project_manager.h @@ -88,6 +88,8 @@ class ProjectManager : public Control { void _load_recent_projects(); void _scan_dir(DirAccess *da,float pos, float total,List<String> *r_projects); + void _install_project(const String& p_zip_path,const String& p_title); + void _panel_draw(Node *p_hb); void _panel_input(const InputEvent& p_ev,Node *p_hb); void _favorite_pressed(Node *p_hb); diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 6822e50b73..6be1abf52f 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -100,16 +100,6 @@ void ProjectSettings::_notification(int p_what) { translation_res_file_open->add_filter("*."+E->get()); translation_res_option_file_open->add_filter("*."+E->get()); } - - List<String> afn; - ResourceLoader::get_recognized_extensions_for_type("Script",&afn); - ResourceLoader::get_recognized_extensions_for_type("PackedScene",&afn); - - for (List<String>::Element *E=afn.front();E;E=E->next()) { - - autoload_file_open->add_filter("*."+E->get()); - } - } } @@ -564,7 +554,7 @@ void ProjectSettings::popup_project_settings() { popup_centered_ratio(); globals_editor->update_category_list(); _update_translations(); - _update_autoload(); + autoload_settings->update_autoload(); plugin_settings->update_plugins(); } @@ -616,10 +606,26 @@ void ProjectSettings::_item_add() { String name = catname!="" ? catname+"/"+propname : propname; - Globals::get_singleton()->set(name,value); + undo_redo->create_action("Add Global Property"); + + undo_redo->add_do_property(Globals::get_singleton(), name, value); + undo_redo->add_do_method(Globals::get_singleton(), "set_persisting", name, true); + + if (Globals::get_singleton()->has(name)) { + undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name)); + } else { + undo_redo->add_undo_property(Globals::get_singleton(), name, Variant()); + } + + undo_redo->add_do_method(globals_editor, "update_category_list"); + undo_redo->add_undo_method(globals_editor, "update_category_list"); + + undo_redo->add_do_method(this, "_settings_changed"); + undo_redo->add_undo_method(this, "_settings_changed"); + + undo_redo->commit_action(); globals_editor->set_current_section(catname); - globals_editor->update_category_list(); _settings_changed(); } @@ -633,10 +639,20 @@ void ProjectSettings::_item_del() { String name = catname!="" ? catname+"/"+propname : propname; - Globals::get_singleton()->set(name,Variant()); + undo_redo->create_action("Delete Global Property"); - globals_editor->set_current_section(catname); - globals_editor->update_category_list(); + undo_redo->add_do_property(Globals::get_singleton(), name, Variant()); + + undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name)); + undo_redo->add_undo_method(Globals::get_singleton(), "set_persisting", name, Globals::get_singleton()->is_persisting(name)); + + undo_redo->add_do_method(globals_editor, "update_category_list"); + undo_redo->add_undo_method(globals_editor, "update_category_list"); + + undo_redo->add_do_method(this, "_settings_changed"); + undo_redo->add_undo_method(this, "_settings_changed"); + + undo_redo->commit_action(); _settings_changed(); } @@ -811,263 +827,6 @@ void ProjectSettings::_translation_file_open() { translation_file_open->popup_centered_ratio(); } - -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); -} - -void ProjectSettings::_autoload_file_open() { - - autoload_file_open->popup_centered_ratio(); -} - -void ProjectSettings::_autoload_edited() { - - if (updating_autoload) - return; - - TreeItem *ti = autoload_list->get_edited(); - int column = autoload_list->get_edited_column(); - - if (!ti || (column != 0 && column != 2)) - return; - - if (column == 0) { - String name = ti->get_text(0); - String old_name = selected_autoload.substr(selected_autoload.find("/")+1,selected_autoload.length()); - - if (!name.is_valid_identifier()) { - ti->set_text(0,old_name); - message->set_text(TTR("Invalid name.")+"\n"+TTR("Valid characters:")+" a-z, A-Z, 0-9 or _"); - message->popup_centered(Size2(300,100)); - return; - } - - if (ObjectTypeDB::type_exists(name)) { - ti->set_text(0,old_name); - message->set_text(TTR("Invalid name. Must not collide with an existing engine class name.")); - message->popup_centered(Size2(400,100)); - return; - } - - for(int i=0;i<Variant::VARIANT_MAX;i++) { - if (Variant::get_type_name(Variant::Type(i))==name) { - ti->set_text(0,old_name); - message->set_text(TTR("Invalid name. Must not collide with an existing buit-in type name.")); - message->popup_centered(Size2(400,100)); - return; - } - } - - for(int i=0;i<GlobalConstants::get_global_constant_count();i++) { - if (GlobalConstants::get_global_constant_name(i)==name) { - ti->set_text(0,old_name); - message->set_text(TTR("Invalid name. Must not collide with an existing global constant name.")); - message->popup_centered(Size2(400,100)); - return; - } - } - - if (Globals::get_singleton()->has("autoload/"+name)) { - ti->set_text(0,old_name); - message->set_text(vformat(TTR("Autoload '%s' already exists!"),name)); - message->popup_centered(Size2(300,100)); - return; - } - - updating_autoload = true; - - name = "autoload/"+name; - String path = Globals::get_singleton()->get(selected_autoload); - bool is_persisting = Globals::get_singleton()->is_persisting(selected_autoload); - int order = Globals::get_singleton()->get_order(selected_autoload); - - undo_redo->create_action(TTR("Rename Autoload")); - undo_redo->add_do_property(Globals::get_singleton(),name,path); - undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",name,is_persisting); - undo_redo->add_do_method(Globals::get_singleton(),"set_order",name,order); - undo_redo->add_do_method(Globals::get_singleton(),"clear",selected_autoload); - undo_redo->add_undo_property(Globals::get_singleton(),selected_autoload,path); - undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",selected_autoload,is_persisting); - undo_redo->add_undo_method(Globals::get_singleton(),"set_order",selected_autoload,order); - undo_redo->add_undo_method(Globals::get_singleton(),"clear",name); - undo_redo->add_do_method(this,"_update_autoload"); - undo_redo->add_undo_method(this,"_update_autoload"); - undo_redo->add_do_method(this,"_settings_changed"); - undo_redo->add_undo_method(this,"_settings_changed"); - undo_redo->commit_action(); - - selected_autoload = name; - } else if (column == 2) { - updating_autoload = true; - - bool checked = ti->is_checked(2); - String base = "autoload/"+ti->get_text(0); - String path = Globals::get_singleton()->get(base); - int order = Globals::get_singleton()->get_order(base); - - if (path.begins_with("*")) - path = path.substr(1,path.length()); - - if (checked) - path = "*" + path; - - undo_redo->create_action(TTR("Toggle AutoLoad Globals")); - undo_redo->add_do_property(Globals::get_singleton(),base,path); - undo_redo->add_undo_property(Globals::get_singleton(),base,Globals::get_singleton()->get(base)); - undo_redo->add_do_method(Globals::get_singleton(),"set_order",base,order); // keep order, as config order matters for these - undo_redo->add_undo_method(Globals::get_singleton(),"set_order",base,order); - undo_redo->add_do_method(this,"_update_autoload"); - undo_redo->add_undo_method(this,"_update_autoload"); - undo_redo->add_do_method(this,"_settings_changed"); - undo_redo->add_undo_method(this,"_settings_changed"); - undo_redo->commit_action(); - } - - updating_autoload = false; -} - -void ProjectSettings::_autoload_add() { - - String name = autoload_add_name->get_text(); - if (!name.is_valid_identifier()) { - message->set_text(TTR("Invalid name.")+"\n"+TTR("Valid characters:")+" a-z, A-Z, 0-9 or _"); - message->popup_centered(Size2(300,100)); - return; - - } - - if (ObjectTypeDB::type_exists(name)) { - - message->set_text(TTR("Invalid name. Must not collide with an existing engine class name.")); - message->popup_centered(Size2(300,100)); - return; - - } - - for(int i=0;i<Variant::VARIANT_MAX;i++) { - if (Variant::get_type_name(Variant::Type(i))==name) { - - message->set_text(TTR("Invalid name. Must not collide with an existing buit-in type name.")); - message->popup_centered(Size2(300,100)); - return; - - } - } - - for(int i=0;i<GlobalConstants::get_global_constant_count();i++) { - - if (GlobalConstants::get_global_constant_name(i)==name) { - - message->set_text(TTR("Invalid name. Must not collide with an existing global constant name.")); - message->popup_centered(Size2(300,100)); - return; - } - - } - - String path = autoload_add_path->get_text(); - if (!FileAccess::exists(path)) { - message->set_text("Invalid Path.\nFile does not exist."); - message->popup_centered(Size2(300,100)); - return; - - } - if (!path.begins_with("res://")) { - message->set_text("Invalid Path.\nNot in resource path."); - message->popup_centered(Size2(300,100)); - return; - - } - - undo_redo->create_action(TTR("Add Autoload")); - name = "autoload/"+name; - undo_redo->add_do_property(Globals::get_singleton(),name,"*"+path); - if (Globals::get_singleton()->has(name)) - undo_redo->add_undo_property(Globals::get_singleton(),name,Globals::get_singleton()->get(name)); - else - undo_redo->add_undo_property(Globals::get_singleton(),name,Variant()); - - undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",name,true); - undo_redo->add_do_method(this,"_update_autoload"); - undo_redo->add_undo_method(this,"_update_autoload"); - undo_redo->add_do_method(this,"_settings_changed"); - 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(); -} - -void ProjectSettings::_autoload_delete(Object *p_item,int p_column, int p_button) { - - - TreeItem *ti=p_item->cast_to<TreeItem>(); - String name = "autoload/"+ti->get_text(0); - - if (p_button==0) { - //delete - int order = Globals::get_singleton()->get_order(name); - undo_redo->create_action(TTR("Remove Autoload")); - undo_redo->add_do_property(Globals::get_singleton(),name,Variant()); - undo_redo->add_undo_property(Globals::get_singleton(),name,Globals::get_singleton()->get(name)); - undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",name,true); - undo_redo->add_undo_method(Globals::get_singleton(),"set_order",name,order); - undo_redo->add_do_method(this,"_update_autoload"); - undo_redo->add_undo_method(this,"_update_autoload"); - undo_redo->add_do_method(this,"_settings_changed"); - undo_redo->add_undo_method(this,"_settings_changed"); - undo_redo->commit_action(); - } else { - - TreeItem *swap = NULL; - - if (p_button==1) { - swap=ti->get_prev(); - } else if (p_button==2) { - swap=ti->get_next(); - } - if (!swap) - return; - - String swap_name= "autoload/"+swap->get_text(0); - - int order = Globals::get_singleton()->get_order(name); - int swap_order = Globals::get_singleton()->get_order(swap_name); - - undo_redo->create_action(TTR("Move Autoload")); - undo_redo->add_do_method(Globals::get_singleton(),"set_order",swap_name,order); - undo_redo->add_do_method(Globals::get_singleton(),"set_order",name,swap_order); - undo_redo->add_undo_method(Globals::get_singleton(),"set_order",swap_name,swap_order); - undo_redo->add_undo_method(Globals::get_singleton(),"set_order",name,order); - undo_redo->add_do_method(this,"_update_autoload"); - undo_redo->add_undo_method(this,"_update_autoload"); - undo_redo->add_do_method(this,"_settings_changed"); - undo_redo->add_undo_method(this,"_settings_changed"); - undo_redo->commit_action(); - - } - -} - -void ProjectSettings::_autoload_selected() { - TreeItem *ti = autoload_list->get_selected(); - - if (!ti) - return; - - selected_autoload = "autoload/"+ti->get_text(0); -} - void ProjectSettings::_translation_delete(Object *p_item,int p_column, int p_button) { TreeItem *ti = p_item->cast_to<TreeItem>(); @@ -1393,55 +1152,6 @@ void ProjectSettings::_update_translations() { } -void ProjectSettings::_update_autoload() { - - if (updating_autoload) - return; - - updating_autoload=true; - - autoload_list->clear(); - TreeItem *root = autoload_list->create_item(); - autoload_list->set_hide_root(true); - - List<PropertyInfo> props; - Globals::get_singleton()->get_property_list(&props); - - for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) { - - const PropertyInfo &pi=E->get(); - if (!pi.name.begins_with("autoload/")) - continue; - - String name = pi.name.get_slice("/",1); - String path = Globals::get_singleton()->get(pi.name); - - if (name=="") - continue; - bool global=false; - if (path.begins_with("*")) { - path=path.substr(1,path.length()); - global=true; - } - TreeItem *t = autoload_list->create_item(root); - t->set_text(0,name); - t->set_editable(0,true); - t->set_text(1,path); - t->set_cell_mode(2,TreeItem::CELL_MODE_CHECK); - t->set_editable(2,true); - t->set_text(2,TTR("Enable")); - t->set_checked(2,global); - t->add_button(3,get_icon("MoveUp","EditorIcons"),1); - t->add_button(3,get_icon("MoveDown","EditorIcons"),2); - t->add_button(3,get_icon("Del","EditorIcons"),0); - - - } - - updating_autoload=false; - -} - void ProjectSettings::_toggle_search_bar(bool p_pressed) { globals_editor->get_property_editor()->set_use_filter(p_pressed); @@ -1508,14 +1218,6 @@ void ProjectSettings::_bind_methods() { ObjectTypeDB::bind_method(_MD("_translation_res_delete"),&ProjectSettings::_translation_res_delete); ObjectTypeDB::bind_method(_MD("_translation_res_option_delete"),&ProjectSettings::_translation_res_option_delete); - ObjectTypeDB::bind_method(_MD("_autoload_add"),&ProjectSettings::_autoload_add); - ObjectTypeDB::bind_method(_MD("_autoload_file_open"),&ProjectSettings::_autoload_file_open); - ObjectTypeDB::bind_method(_MD("_autoload_file_callback"),&ProjectSettings::_autoload_file_callback); - ObjectTypeDB::bind_method(_MD("_update_autoload"),&ProjectSettings::_update_autoload); - ObjectTypeDB::bind_method(_MD("_autoload_delete"),&ProjectSettings::_autoload_delete); - ObjectTypeDB::bind_method(_MD("_autoload_edited"),&ProjectSettings::_autoload_edited); - ObjectTypeDB::bind_method(_MD("_autoload_selected"),&ProjectSettings::_autoload_selected); - ObjectTypeDB::bind_method(_MD("_clear_search_box"),&ProjectSettings::_clear_search_box); ObjectTypeDB::bind_method(_MD("_toggle_search_bar"),&ProjectSettings::_toggle_search_bar); @@ -1858,69 +1560,10 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { { - VBoxContainer *avb = memnew( VBoxContainer ); - tab_container->add_child(avb); - avb->set_name(TTR("AutoLoad")); - HBoxContainer *ahb = memnew( HBoxContainer); - avb->add_child(ahb); - - - VBoxContainer *avb_path = memnew( VBoxContainer ); - avb_path->set_h_size_flags(SIZE_EXPAND_FILL); - HBoxContainer *ahb_path = memnew( HBoxContainer ); - autoload_add_path = memnew(LineEdit); - autoload_add_path->set_h_size_flags(SIZE_EXPAND_FILL); - ahb_path->add_child(autoload_add_path); - Button *browseaa = memnew( Button("..") ); - ahb_path->add_child(browseaa); - browseaa->connect("pressed",this,"_autoload_file_open"); - - avb_path->add_margin_child(TTR("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(TTR("Node Name:"),ahb_name); - Button *addaa = memnew( Button(TTR("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(TTR("List:"),autoload_list,true); - - autoload_file_open=memnew( EditorFileDialog ); - add_child(autoload_file_open); - autoload_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE); - autoload_file_open->connect("file_selected",this,"_autoload_file_callback"); - - autoload_list->set_columns(4); - autoload_list->set_column_titles_visible(true); - autoload_list->set_column_title(0,TTR("Name")); - autoload_list->set_column_expand(0,true); - autoload_list->set_column_min_width(0,100); - autoload_list->set_column_title(1,TTR("Path")); - autoload_list->set_column_expand(1,true); - autoload_list->set_column_min_width(1,100); - autoload_list->set_column_title(2,TTR("Singleton")); - autoload_list->set_column_expand(2,false); - autoload_list->set_column_min_width(2,80); - autoload_list->set_column_expand(3,false); - autoload_list->set_column_min_width(3,80); - - autoload_list->connect("button_pressed",this,"_autoload_delete"); - autoload_list->connect("item_edited",this,"_autoload_edited"); - autoload_list->connect("cell_selected", this, "_autoload_selected"); - - updating_autoload=false; - + autoload_settings = memnew( EditorAutoloadSettings ); + autoload_settings->set_name(TTR("AutoLoad")); + tab_container->add_child(autoload_settings); + autoload_settings->connect("autoload_changed", this, "_settings_changed"); } { diff --git a/tools/editor/project_settings.h b/tools/editor/project_settings.h index 79e1acf75e..46e98f69ad 100644 --- a/tools/editor/project_settings.h +++ b/tools/editor/project_settings.h @@ -34,6 +34,7 @@ #include "undo_redo.h" #include "editor_data.h" #include "scene/gui/tab_container.h" +#include "editor_autoload_settings.h" #include "editor_plugin_settings.h" //#include "project_export_settings.h" @@ -88,26 +89,10 @@ class ProjectSettings : public AcceptDialog { Tree *translation_remap; Tree *translation_remap_options; - - Tree *autoload_list; - String selected_autoload; - EditorFileDialog *autoload_file_open; - LineEdit *autoload_add_name; - LineEdit *autoload_add_path; - + EditorAutoloadSettings *autoload_settings; EditorPluginSettings *plugin_settings; - void _update_autoload(); - void _autoload_file_callback(const String& p_path); - void _autoload_add(); - void _autoload_edited(); - void _autoload_file_open(); - void _autoload_delete(Object *p_item,int p_column, int p_button); - void _autoload_selected(); - bool updating_autoload; - - void _item_selected(); void _item_adds(String); void _item_add(); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 246785932d..ceb62d5ff0 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -389,7 +389,6 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty List<String> names; names.push_back("value:"); config_value_editors(1,1,50,names); - Vector3 vec=v; value_editor[0]->set_text( String::num(v) ); } @@ -436,7 +435,6 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty List<String> names; names.push_back("string:"); config_value_editors(1,1,50,names); - Vector3 vec=v; value_editor[0]->set_text( v ); } @@ -612,6 +610,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA); color_picker->set_color(v); set_size( Size2(300*EDSCALE, color_picker->get_combined_minimum_size().height+10*EDSCALE)); + color_picker->set_focus_on_line_edit(); /* int ofs=80; int m=10; @@ -2980,10 +2979,8 @@ void PropertyEditor::update_tree() { else item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE_EXPRESSION ); - if (p.hint==PROPERTY_HINT_SPRITE_FRAME) { - item->set_range_config(1,0,99999,1); - } else if (p.hint==PROPERTY_HINT_RANGE || p.hint==PROPERTY_HINT_EXP_RANGE) { + if (p.hint==PROPERTY_HINT_SPRITE_FRAME || p.hint==PROPERTY_HINT_RANGE || p.hint==PROPERTY_HINT_EXP_RANGE) { int c = p.hint_string.get_slice_count(","); float min=0,max=100,step=1; @@ -3346,7 +3343,6 @@ void PropertyEditor::update_tree() { String type; if (p.hint==PROPERTY_HINT_RESOURCE_TYPE) type=p.hint_string; - bool notnil=false; if (obj->get( p.name ).get_type() == Variant::NIL || obj->get( p.name ).operator RefPtr().is_null()) { item->set_text(1,"<null>"); @@ -3369,8 +3365,7 @@ void PropertyEditor::update_tree() { } else { item->set_text(1,"<"+res->get_type()+">"); - }; - notnil=true; + } if (has_icon(res->get_type(),"EditorIcons")) { type=res->get_type(); @@ -4192,6 +4187,8 @@ public: void SectionedPropertyEditor::_bind_methods() { ObjectTypeDB::bind_method("_section_selected",&SectionedPropertyEditor::_section_selected); + + ObjectTypeDB::bind_method("update_category_list", &SectionedPropertyEditor::update_category_list); } void SectionedPropertyEditor::_section_selected(int p_which) { diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp index fc2a2241ab..e18dc584d5 100644 --- a/tools/editor/quick_open.cpp +++ b/tools/editor/quick_open.cpp @@ -109,16 +109,27 @@ void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) { } -void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) { +float EditorQuickOpen::_path_cmp(String search, String path) const { + + if (search == path) { + return 1.2f; + } + if (path.findn(search) != -1) { + return 1.1f; + } + return path.to_lower().similarity(search.to_lower()); +} + +void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< String, Ref<Texture> > > &list) { if (!add_directories) { for(int i=0;i<efsd->get_subdir_count();i++) { - _parse_fs(efsd->get_subdir(i)); + _parse_fs(efsd->get_subdir(i), list); } } - TreeItem *root = search_options->get_root(); + String search_text = search_box->get_text(); if (add_directories) { String path = efsd->get_path(); @@ -126,11 +137,27 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) { path+="/"; if (path!="res://") { path=path.substr(6,path.length()); - if (search_box->get_text().is_subsequence_ofi(path)) { - TreeItem *ti = search_options->create_item(root); - ti->set_text(0,path); - Ref<Texture> icon = get_icon("folder","FileDialog"); - ti->set_icon(0,icon); + if (search_text.is_subsequence_ofi(path)) { + Pair< String, Ref<Texture> > pair; + pair.first = path; + pair.second = get_icon("folder", "FileDialog"); + + if (search_text != String() && list.size() > 0) { + + float this_sim = _path_cmp(search_text, path); + float other_sim = _path_cmp(list[0].first, path); + int pos = 1; + + while (pos < list.size() && this_sim <= other_sim) { + other_sim = _path_cmp(list[pos++].first, path); + } + + pos = this_sim >= other_sim ? pos - 1 : pos; + list.insert(pos, pair); + + } else { + list.push_back(pair); + } } } } @@ -138,12 +165,29 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) { String file = efsd->get_file_path(i); file=file.substr(6,file.length()); - if (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_box->get_text().is_subsequence_ofi(file))) { - TreeItem *ti = search_options->create_item(root); - ti->set_text(0,file); - Ref<Texture> icon = get_icon( (has_icon(efsd->get_file_type(i),ei)?efsd->get_file_type(i):ot),ei); - ti->set_icon(0,icon); + if (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_text.is_subsequence_ofi(file))) { + Pair< String, Ref<Texture> > pair; + pair.first = file; + pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei); + + if (search_text != String() && list.size() > 0) { + + float this_sim = _path_cmp(search_text, file); + float other_sim = _path_cmp(list[0].first, file); + int pos = 1; + + while (pos < list.size() && this_sim <= other_sim) { + other_sim = _path_cmp(list[pos++].first, file); + } + + pos = this_sim >= other_sim ? pos - 1 : pos; + list.insert(pos, pair); + + } else { + + list.push_back(pair); + } } } @@ -151,7 +195,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) { if (add_directories) { for(int i=0;i<efsd->get_subdir_count();i++) { - _parse_fs(efsd->get_subdir(i)); + _parse_fs(efsd->get_subdir(i), list); } } @@ -159,10 +203,18 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) { void EditorQuickOpen::_update_search() { - search_options->clear(); TreeItem *root = search_options->create_item(); - _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); + EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem(); + Vector< Pair< String, Ref<Texture> > > list; + + _parse_fs(efsd, list); + + for (int i = 0; i < list.size(); i++) { + TreeItem *ti = search_options->create_item(root); + ti->set_text(0, list[i].first); + ti->set_icon(0, list[i].second); + } if (root->get_children()) { TreeItem *ti = root->get_children(); diff --git a/tools/editor/quick_open.h b/tools/editor/quick_open.h index 520f7e569d..c253f7606e 100644 --- a/tools/editor/quick_open.h +++ b/tools/editor/quick_open.h @@ -32,6 +32,7 @@ #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" #include "editor_file_system.h" +#include "pair.h" class EditorQuickOpen : public ConfirmationDialog { OBJ_TYPE(EditorQuickOpen,ConfirmationDialog ) @@ -47,7 +48,8 @@ class EditorQuickOpen : public ConfirmationDialog { void _update_search(); void _sbox_input(const InputEvent& p_ie); - void _parse_fs(EditorFileSystemDirectory *efsd); + void _parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< String,Ref <Texture> > > &list); + float _path_cmp(String search, String path) const; void _confirmed(); diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 30ffdf6664..2e7d65eadc 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -39,16 +39,20 @@ #include "multi_node_edit.h" #include "tools/editor/plugins/animation_player_editor_plugin.h" #include "animation_editor.h" - +#include "scene/main/viewport.h" void SceneTreeDock::_unhandled_key_input(InputEvent p_event) { + if (get_viewport()->get_modal_stack_top()) + return; //ignore because of modal window + uint32_t sc = p_event.key.get_scancode_with_modifiers(); if (!p_event.key.pressed || p_event.key.echo) return; + if (ED_IS_SHORTCUT("scene_tree/add_child_node", p_event)) { _tool_selected(TOOL_NEW); } @@ -239,7 +243,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { //if (!_validate_no_foreign()) // break; - create_dialog->popup_centered_ratio(); + create_dialog->popup(true); } break; case TOOL_INSTANCE: { @@ -277,7 +281,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_REPLACE: { - create_dialog->popup_centered_ratio(); + create_dialog->popup(false); } break; case TOOL_CONNECT: { @@ -378,11 +382,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { ERR_FAIL_COND(!top_node->get_parent()); ERR_FAIL_COND(!bottom_node->get_parent()); - int top_node_pos = top_node->get_index(); int bottom_node_pos = bottom_node->get_index(); - - int top_node_pos_next = top_node_pos + (MOVING_DOWN ? 1 : -1); - int bottom_node_pos_next = bottom_node_pos + (MOVING_DOWN ? 1 : -1); + int top_node_pos_next = top_node->get_index() + (MOVING_DOWN ? 1 : -1); editor_data->get_undo_redo().add_do_method(top_node->get_parent(), "move_child", top_node, top_node_pos_next); editor_data->get_undo_redo().add_undo_method(bottom_node->get_parent(), "move_child", bottom_node, bottom_node_pos); @@ -1065,6 +1066,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec List<Pair<NodePath,NodePath> > path_renames; + int inc=0; + for(int ni=0;ni<p_nodes.size();ni++) { //no undo for now, sorry @@ -1081,12 +1084,16 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec } + if (new_parent==node->get_parent() && node->get_index() < p_position_in_parent+ni) { + //if child will generate a gap when moved, adjust + inc--; + } editor_data->get_undo_redo().add_do_method(node->get_parent(),"remove_child",node); editor_data->get_undo_redo().add_do_method(new_parent,"add_child",node); if (p_position_in_parent>=0) - editor_data->get_undo_redo().add_do_method(new_parent,"move_child",node,p_position_in_parent+ni); + editor_data->get_undo_redo().add_do_method(new_parent,"move_child",node,p_position_in_parent+inc); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); String new_name = new_parent->validate_child_name(node->get_name()); @@ -1098,17 +1105,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Node2D>()->get_global_transform()); if (node->cast_to<Spatial>()) editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Spatial>()->get_global_transform()); - if (node->cast_to<Control>()) { - bool can_do_it=false; - Control *c=node->cast_to<Control>(); - if (c->get_parent()->cast_to<Container>()) - can_do_it=false; - for(int i=0;i<4;i++) { - if (c->get_anchor(Margin(i))!=ANCHOR_BEGIN) - can_do_it=false; - } + if (node->cast_to<Control>()) editor_data->get_undo_redo().add_do_method(node,"set_global_pos",node->cast_to<Control>()->get_global_pos()); - } } editor_data->get_undo_redo().add_do_method(this,"_set_owners",edited_scene,owners); @@ -1118,6 +1116,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_undo_method(new_parent,"remove_child",node); + inc++; + } //add and move in a second step.. (so old order is preserved) @@ -1149,17 +1149,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Node2D>()->get_transform()); if (node->cast_to<Spatial>()) editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Spatial>()->get_transform()); - if (node->cast_to<Control>()) { - bool can_do_it=false; - Control *c=node->cast_to<Control>(); - if (c->get_parent()->cast_to<Container>()) - can_do_it=false; - for(int i=0;i<4;i++) { - if (c->get_anchor(Margin(i))!=ANCHOR_BEGIN) - can_do_it=false; - } + if (node->cast_to<Control>()) editor_data->get_undo_redo().add_undo_method(node,"set_pos",node->cast_to<Control>()->get_pos()); - } } @@ -1539,7 +1530,7 @@ static bool _has_visible_children(Node* p_node) { for(int i=0;i<p_node->get_child_count();i++) { Node* child = p_node->get_child(i); - if (!_is_node_visible(p_node)) + if (!_is_node_visible(child)) continue; return true; @@ -1551,9 +1542,9 @@ static bool _has_visible_children(Node* p_node) { -static Node* _find_last_visible(Node*p_node) { +static Node* _find_last_visible(Node* p_node) { - Node*last=NULL; + Node* last=NULL; bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false; @@ -1579,7 +1570,7 @@ static Node* _find_last_visible(Node*p_node) { } -void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos,int p_type) { +void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos, int p_type) { to_pos=-1; @@ -1620,6 +1611,7 @@ void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos,int p_type) { //just insert over this node because nothing is above at the same level to_pos=to_node->get_index(); to_node=to_node->get_parent(); + } } else if (p_type==1) { @@ -1646,12 +1638,13 @@ void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos,int p_type) { break; } } - if (lower_sibling) { to_pos=lower_sibling->get_index(); } to_node=to_node->get_parent(); + + } #if 0 //quite complicated, look for next visible in tree diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h index 60bec9b4f4..51041a235b 100644 --- a/tools/editor/scene_tree_dock.h +++ b/tools/editor/scene_tree_dock.h @@ -139,7 +139,7 @@ class SceneTreeDock : public VBoxContainer { void _fill_path_renames(Vector<StringName> base_path,Vector<StringName> new_base_path,Node * p_node, List<Pair<NodePath,NodePath> > *p_renames); - void _normalize_drop(Node*& to_node, int &to_pos,int p_type); + void _normalize_drop(Node*& to_node, int &to_pos, int p_type); void _nodes_dragged(Array p_nodes,NodePath p_to,int p_type); void _files_dropped(Vector<String> p_files,NodePath p_to,int p_type); diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index a155f0c0cf..cc11cbc562 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -260,13 +260,21 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) } else if (p_id==BUTTON_SIGNALS) { - item->select(0); + editor_selection->clear(); + editor_selection->add_node(n); + + set_selected(n); + NodeDock::singleton->get_parent()->call("set_current_tab",NodeDock::singleton->get_index()); NodeDock::singleton->show_connections(); } else if (p_id==BUTTON_GROUPS) { - item->select(0); + editor_selection->clear(); + editor_selection->add_node(n); + + set_selected(n); + NodeDock::singleton->get_parent()->call("set_current_tab",NodeDock::singleton->get_index()); NodeDock::singleton->show_groups(); } @@ -302,8 +310,15 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) { item->set_selectable(0,true); if (can_rename) { - - bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false; +#ifdef ENABLE_DEPRECATED + if (p_node->has_meta("_editor_collapsed")) { + //remove previous way of storing folding, which did not get along with scene inheritance and instancing + if ((bool)p_node->get_meta("_editor_collapsed")) + p_node->set_display_folded(true); + p_node->set_meta("_editor_collapsed",Variant()); + } +#endif + bool collapsed = p_node->is_displayed_folded(); if (collapsed) item->set_collapsed(true); } @@ -896,10 +911,7 @@ void SceneTreeEditor::_cell_collapsed(Object *p_obj) { Node *n=get_node(np); ERR_FAIL_COND(!n); - if (collapsed) - n->set_meta("_editor_collapsed",true); - else - n->set_meta("_editor_collapsed",Variant()); + n->set_display_folded(collapsed); } diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp index 44832c84eb..75c983994e 100644 --- a/tools/editor/scenes_dock.cpp +++ b/tools/editor/scenes_dock.cpp @@ -37,6 +37,8 @@ #include "editor_settings.h" #include "scene/main/viewport.h" + + bool ScenesDock::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) { @@ -57,60 +59,8 @@ bool ScenesDock::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_di item->select(0); } - - //item->set_custom_bg_color(0,get_color("prop_subsection","Editor")); - - bool has_items=false; - - for(int i=0;i<p_dir->get_subdir_count();i++) { - - if (_create_tree(item,p_dir->get_subdir(i))) - has_items=true; - } -#if 0 - for (int i=0;i<p_dir->get_file_count();i++) { - - String file_name = p_dir->get_file(i); - String file_path = p_dir->get_file_path(i); - - // ScenesDockFilter::FILTER_PATH - String search_from = file_path.right(6); // trim "res://" - if (file_filter == ScenesDockFilter::FILTER_NAME) - search_from = file_name; - else if (file_filter == ScenesDockFilter::FILTER_FOLDER) - search_from = file_path.right(6).get_base_dir(); - - if (search_term!="" && search_from.findn(search_term)==-1) - continue; - - bool isfave = favorites.has(file_path); - if (button_favorite->is_pressed() && !isfave) - continue; - - TreeItem *fitem = tree->create_item(item); - fitem->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); - fitem->set_editable(0,true); - fitem->set_checked(0,isfave); - fitem->set_text(0,file_name); - - Ref<Texture> icon = get_icon( (has_icon(p_dir->get_file_type(i),"EditorIcons")?p_dir->get_file_type(i):String("Object")),"EditorIcons"); - fitem->set_icon(0, icon ); - - - fitem->set_metadata(0,file_path); - //if (p_dir->files[i]->icon.is_valid()) { -// fitem->set_icon(0,p_dir->files[i]->icon); -// } - has_items=true; - - } -#endif - /*if (!has_items) { - - memdelete(item); - return false; - - }*/ + for(int i=0;i<p_dir->get_subdir_count();i++) + _create_tree(item,p_dir->get_subdir(i)); return true; } @@ -164,12 +114,14 @@ void ScenesDock::_notification(int p_what) { if (split_mode) { file_list_vb->hide(); + tree->set_custom_minimum_size(Size2(0,0)); tree->set_v_size_flags(SIZE_EXPAND_FILL); button_back->show(); } else { tree->show(); file_list_vb->show(); + tree->set_custom_minimum_size(Size2(0,200)*EDSCALE); tree->set_v_size_flags(SIZE_FILL); button_back->hide(); if (!EditorFileSystem::get_singleton()->is_scanning()) { @@ -187,6 +139,7 @@ void ScenesDock::_notification(int p_what) { initialized=true; EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_fs_changed"); + EditorResourcePreview::get_singleton()->connect("preview_invalidated",this,"_preview_invalidated"); button_reload->set_icon( get_icon("Reload","EditorIcons")); button_favorite->set_icon( get_icon("Favorites","EditorIcons")); @@ -661,6 +614,27 @@ void ScenesDock::_go_to_dir(const String& p_dir){ } + +void ScenesDock::_preview_invalidated(const String& p_path) { + + if (p_path.get_base_dir()==path && search_box->get_text()==String() && file_list_vb->is_visible()) { + + + for(int i=0;i<files->get_item_count();i++) { + + if (files->get_item_metadata(i)==p_path) { + //re-request preview + Array udata; + udata.resize(2); + udata[0]=i; + udata[1]=files->get_item_text(i); + EditorResourcePreview::get_singleton()->queue_resource_preview(p_path,this,"_thumbnail_done",udata); + break; + } + } + } +} + void ScenesDock::_fs_changed() { button_hist_prev->set_disabled(history_pos==0); @@ -1618,6 +1592,9 @@ void ScenesDock::_bind_methods() { ObjectTypeDB::bind_method(_MD("drop_data_fw"), &ScenesDock::drop_data_fw); ObjectTypeDB::bind_method(_MD("_files_list_rmb_select"),&ScenesDock::_files_list_rmb_select); + ObjectTypeDB::bind_method(_MD("_preview_invalidated"),&ScenesDock::_preview_invalidated); + + ADD_SIGNAL(MethodInfo("instance")); ADD_SIGNAL(MethodInfo("open")); @@ -1668,7 +1645,7 @@ ScenesDock::ScenesDock(EditorNode *p_editor) { button_favorite->set_focus_mode(FOCUS_NONE); - Control *spacer = memnew( Control); +// Control *spacer = memnew( Control); @@ -1702,7 +1679,6 @@ ScenesDock::ScenesDock(EditorNode *p_editor) { tree->set_hide_root(true); split_box->add_child(tree); - tree->set_custom_minimum_size(Size2(0,200)*EDSCALE); tree->set_drag_forwarding(this); diff --git a/tools/editor/scenes_dock.h b/tools/editor/scenes_dock.h index ed24711abb..0973fce250 100644 --- a/tools/editor/scenes_dock.h +++ b/tools/editor/scenes_dock.h @@ -168,6 +168,8 @@ class ScenesDock : public VBoxContainer { bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const; void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from); + void _preview_invalidated(const String& p_path); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 6d8f54d88f..b6390e5aae 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -338,8 +338,9 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat docontinue->set_disabled(false); emit_signal("breaked",true,can_continue); OS::get_singleton()->move_window_to_foreground(); - if (!profiler->is_seeking()) + if (error!="") { tabs->set_current_tab(0); + } profiler->set_enabled(false); @@ -819,7 +820,6 @@ void ScriptEditorDebugger::_performance_draw() { if(which.empty()) return; - Color graph_color=get_color("font_color","TextEdit"); Ref<StyleBox> graph_sb = get_stylebox("normal","TextEdit"); Ref<Font> graph_font = get_font("font","TextEdit"); diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp index e1a2ea162e..f436e369af 100644 --- a/tools/editor/settings_config_dialog.cpp +++ b/tools/editor/settings_config_dialog.cpp @@ -97,11 +97,24 @@ void EditorSettingsDialog::_clear_search_box() { property_editor->get_property_editor()->update_tree(); } +void EditorSettingsDialog::_clear_shortcut_search_box() { + if (shortcut_search_box->get_text()=="") + return; + + shortcut_search_box->clear(); +} + +void EditorSettingsDialog::_filter_shortcuts(const String& p_filter) { + shortcut_filter = p_filter; + _update_shortcuts(); +} + void EditorSettingsDialog::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { clear_button->set_icon(get_icon("Close","EditorIcons")); + shortcut_clear_button->set_icon(get_icon("Close","EditorIcons")); } } @@ -137,26 +150,30 @@ void EditorSettingsDialog::_update_shortcuts() { sections[section_name]=section; section->set_custom_bg_color(0,get_color("prop_subsection","Editor")); section->set_custom_bg_color(1,get_color("prop_subsection","Editor")); - } - TreeItem *item = shortcuts->create_item(section); - - - item->set_text(0,sc->get_name()); - item->set_text(1,sc->get_as_text()); - if (!sc->is_shortcut(original) && !(sc->get_shortcut().type==InputEvent::NONE && original.type==InputEvent::NONE)) { - item->add_button(1,get_icon("Reload","EditorIcons"),2); + if (shortcut_filter.is_subsequence_ofi(sc->get_name())) { + TreeItem *item = shortcuts->create_item(section); + + item->set_text(0,sc->get_name()); + item->set_text(1,sc->get_as_text()); + if (!sc->is_shortcut(original) && !(sc->get_shortcut().type==InputEvent::NONE && original.type==InputEvent::NONE)) { + item->add_button(1,get_icon("Reload","EditorIcons"),2); + } + item->add_button(1,get_icon("Edit","EditorIcons"),0); + item->add_button(1,get_icon("Close","EditorIcons"),1); + item->set_tooltip(0,E->get()); + item->set_metadata(0,E->get()); } - item->add_button(1,get_icon("Edit","EditorIcons"),0); - item->add_button(1,get_icon("Close","EditorIcons"),1); - item->set_tooltip(0,E->get()); - item->set_metadata(0,E->get()); } - - - + // remove sections with no shortcuts + for(Map<String,TreeItem*>::Element *E=sections.front();E;E=E->next()) { + TreeItem *section = E->get(); + if (section->get_children() == NULL) { + root->remove_child(section); + } + } } void EditorSettingsDialog::_shortcut_button_pressed(Object* p_item,int p_column,int p_idx) { @@ -265,7 +282,9 @@ void EditorSettingsDialog::_bind_methods() { ObjectTypeDB::bind_method(_MD("_settings_save"),&EditorSettingsDialog::_settings_save); ObjectTypeDB::bind_method(_MD("_settings_changed"),&EditorSettingsDialog::_settings_changed); ObjectTypeDB::bind_method(_MD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box); + ObjectTypeDB::bind_method(_MD("_clear_shortcut_search_box"),&EditorSettingsDialog::_clear_shortcut_search_box); ObjectTypeDB::bind_method(_MD("_shortcut_button_pressed"),&EditorSettingsDialog::_shortcut_button_pressed); + ObjectTypeDB::bind_method(_MD("_filter_shortcuts"),&EditorSettingsDialog::_filter_shortcuts); ObjectTypeDB::bind_method(_MD("_update_shortcuts"),&EditorSettingsDialog::_update_shortcuts); ObjectTypeDB::bind_method(_MD("_press_a_key_confirm"),&EditorSettingsDialog::_press_a_key_confirm); ObjectTypeDB::bind_method(_MD("_wait_for_key"),&EditorSettingsDialog::_wait_for_key); @@ -311,6 +330,23 @@ EditorSettingsDialog::EditorSettingsDialog() { tabs->add_child(vbc); vbc->set_name(TTR("Shortcuts")); + hbc = memnew( HBoxContainer ); + hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); + vbc->add_child(hbc); + + l = memnew( Label ); + l->set_text(TTR("Search:")+" "); + hbc->add_child(l); + + shortcut_search_box = memnew( LineEdit ); + shortcut_search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); + hbc->add_child(shortcut_search_box); + shortcut_search_box->connect("text_changed", this, "_filter_shortcuts"); + + shortcut_clear_button = memnew( ToolButton ); + hbc->add_child(shortcut_clear_button); + shortcut_clear_button->connect("pressed",this,"_clear_shortcut_search_box"); + shortcuts = memnew( Tree ); vbc->add_margin_child("Shortcut List:",shortcuts,true); shortcuts->set_columns(2); diff --git a/tools/editor/settings_config_dialog.h b/tools/editor/settings_config_dialog.h index c930de6a77..68a2b008f0 100644 --- a/tools/editor/settings_config_dialog.h +++ b/tools/editor/settings_config_dialog.h @@ -45,7 +45,9 @@ class EditorSettingsDialog : public AcceptDialog { TabContainer *tabs; LineEdit *search_box; + LineEdit *shortcut_search_box; ToolButton *clear_button; + ToolButton *shortcut_clear_button; SectionedPropertyEditor *property_editor; Timer *timer; @@ -56,6 +58,7 @@ class EditorSettingsDialog : public AcceptDialog { Label *press_a_key_label; InputEvent last_wait_for_key; String shortcut_configured; + String shortcut_filter; virtual void cancel_pressed(); virtual void ok_pressed(); @@ -69,8 +72,11 @@ class EditorSettingsDialog : public AcceptDialog { void _press_a_key_confirm(); void _wait_for_key(const InputEvent& p_event); + void _clear_shortcut_search_box(); void _clear_search_box(); + void _filter_shortcuts(const String& p_filter); + void _update_shortcuts(); void _shortcut_button_pressed(Object* p_item,int p_column,int p_idx); diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index 1ca62d3a63..480d33fd0a 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -424,16 +424,11 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po } Transform ti=t.affine_inverse(); - Vector3 ray_from=ti.xform(p_camera->project_ray_origin(p_point)); - Vector3 ray_dir=t.basis.xform_inv(p_camera->project_ray_normal(p_point)).normalized(); - Vector3 ray_to = ray_from+ray_dir*4096; float min_d=1e20; int idx=-1; for(int i=0;i<secondary_handles.size();i++) { -#if 1 - Vector3 hpos = t.xform(secondary_handles[i]); Vector2 p = p_camera->unproject_position(hpos); @@ -449,31 +444,7 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po idx=i+handles.size(); } - } - -#else - AABB aabb; - aabb.pos=Vector3(-1,-1,-1)*HANDLE_HALF_SIZE; - aabb.size=aabb.pos*-2; - aabb.pos+=secondary_handles[i]; - - - Vector3 rpos,rnorm; - - if (aabb.intersects_segment(ray_from,ray_to,&rpos,&rnorm)) { - - real_t dp = ray_dir.dot(rpos); - if (dp<min_d) { - - r_pos=t.xform(rpos); - r_normal=ti.basis.xform_inv(rnorm).normalized(); - min_d=dp; - idx=i+handles.size(); - - } - } -#endif } if (p_sec_first && idx!=-1) { @@ -486,9 +457,6 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po for(int i=0;i<handles.size();i++) { -#if 1 - - Vector3 hpos = t.xform(handles[i]); Vector2 p = p_camera->unproject_position(hpos); if (p.distance_to(p_point)<SpatialEditorGizmos::singleton->handle_t->get_width()*0.6) { @@ -503,32 +471,7 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po idx=i; } - - } - -#else - - AABB aabb; - aabb.pos=Vector3(-1,-1,-1)*HANDLE_HALF_SIZE; - aabb.size=aabb.pos*-2; - aabb.pos+=handles[i]; - - - Vector3 rpos,rnorm; - - if (aabb.intersects_segment(ray_from,ray_to,&rpos,&rnorm)) { - - real_t dp = ray_dir.dot(rpos); - if (dp<min_d) { - - r_pos=t.xform(rpos); - r_normal=ti.basis.xform_inv(rnorm).normalized(); - min_d=dp; - idx=i; - - } } -#endif } if (idx>=0) { @@ -612,9 +555,6 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po Vector3 ray_dir=ai.basis.xform(p_camera->project_ray_normal(p_point)).normalized(); Vector3 rpos,rnorm; -#if 1 - - if (collision_mesh->intersect_ray(ray_from,ray_dir,rpos,rnorm)) { @@ -622,16 +562,6 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po r_normal=gt.basis.xform(rnorm).normalized(); return true; } -#else - - if (collision_mesh->intersect_segment(ray_from,ray_from+ray_dir*4906.0,rpos,rnorm)) { - - r_pos=gt.xform(rpos); - r_normal=gt.basis.xform(rnorm).normalized(); - return true; - } - -#endif } return false; @@ -693,12 +623,11 @@ void EditorSpatialGizmo::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_unscaled_billboard","material:Material","default_scale"),&EditorSpatialGizmo::add_unscaled_billboard,DEFVAL(1)); ObjectTypeDB::bind_method(_MD("add_handles","handles","billboard","secondary"),&EditorSpatialGizmo::add_handles,DEFVAL(false),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("set_spatial_node","node:Spatial"),&EditorSpatialGizmo::_set_spatial_node); + ObjectTypeDB::bind_method(_MD("clear"),&EditorSpatialGizmo::clear); BIND_VMETHOD( MethodInfo("redraw")); BIND_VMETHOD( MethodInfo(Variant::STRING,"get_handle_name",PropertyInfo(Variant::INT,"index"))); - { - BIND_VMETHOD( MethodInfo("get_handle_value:Variant",PropertyInfo(Variant::INT,"index"))); - } + BIND_VMETHOD( MethodInfo("get_handle_value:Variant",PropertyInfo(Variant::INT,"index"))); BIND_VMETHOD( MethodInfo("set_handle",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::OBJECT,"camera:Camera"),PropertyInfo(Variant::VECTOR2,"point"))); MethodInfo cm = MethodInfo("commit_handle",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::NIL,"restore:Variant"),PropertyInfo(Variant::BOOL,"cancel")); cm.default_arguments.push_back(false); @@ -2250,7 +2179,6 @@ void VisibilityNotifierGizmo::set_handle(int p_idx,Camera *p_camera, const Point if (d<0.001) d=0.001; - Vector3 he = aabb.size; aabb.pos[p_idx]=(aabb.pos[p_idx]+aabb.size[p_idx]*0.5)-d; aabb.size[p_idx]=d*2; notifier->set_aabb(aabb); @@ -2456,8 +2384,6 @@ void HingeJointSpatialGizmo::redraw() { if (p3d->get_flag(HingeJoint::FLAG_USE_LIMIT) && ll<ul) { const int points = 32; - float step = (ul-ll)/points; - for(int i=0;i<points;i++) { @@ -2573,8 +2499,6 @@ void SliderJointSpatialGizmo::redraw() { if (ll<ul) { const int points = 32; - float step = (ul-ll)/points; - for(int i=0;i<points;i++) { @@ -2641,7 +2565,6 @@ SliderJointSpatialGizmo::SliderJointSpatialGizmo(SliderJoint* p_p3d) { void ConeTwistJointSpatialGizmo::redraw() { clear(); - float cs = 0.25; Vector<Vector3> points; float r = 1.0; @@ -2837,8 +2760,6 @@ void Generic6DOFJointSpatialGizmo::redraw() { if (enable_ang && ll<=ul) { const int points = 32; - float step = (ul-ll)/points; - for(int i=0;i<points;i++) { |