diff options
Diffstat (limited to 'tools/editor')
-rw-r--r-- | tools/editor/editor_file_system.cpp | 7 | ||||
-rw-r--r-- | tools/editor/editor_file_system.h | 1 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 1 | ||||
-rw-r--r-- | tools/editor/editor_resource_preview.cpp | 34 | ||||
-rw-r--r-- | tools/editor/editor_resource_preview.h | 4 | ||||
-rw-r--r-- | tools/editor/plugins/canvas_item_editor_plugin.cpp | 47 | ||||
-rw-r--r-- | tools/editor/plugins/spatial_editor_plugin.cpp | 263 | ||||
-rw-r--r-- | tools/editor/quick_open.cpp | 74 | ||||
-rw-r--r-- | tools/editor/quick_open.h | 3 | ||||
-rw-r--r-- | tools/editor/scenes_dock.cpp | 25 | ||||
-rw-r--r-- | tools/editor/scenes_dock.h | 2 |
11 files changed, 272 insertions, 189 deletions
diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index 1f414f80a0..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; @@ -848,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; @@ -858,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++) { @@ -1328,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 } @@ -1341,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_node.cpp b/tools/editor/editor_node.cpp index 2bba97251d..ae632ab381 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -2846,6 +2846,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(); } + } diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index 8975c0ec35..750a172d1e 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -66,16 +66,20 @@ 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; @@ -263,6 +267,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 +278,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 +330,32 @@ 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"))); +} + +bool 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..fed8f129ed 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); + bool check_for_invalidation(const String& p_path); EditorResourcePreview(); ~EditorResourcePreview(); diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 81601a81a7..caa09fba35 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -3374,25 +3374,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"); @@ -3409,13 +3409,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_CMD | KEY_F), VIEW_FRAME_TO_SELECTION); anchor_menu = memnew( MenuButton ); anchor_menu->set_text(TTR("Anchor")); @@ -3458,7 +3458,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); @@ -3469,12 +3470,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/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 8d72178f23..201ff30f40 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1658,136 +1658,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; @@ -2470,29 +2423,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 ); @@ -3951,6 +3903,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 +3923,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 +3940,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/quick_open.cpp b/tools/editor/quick_open.cpp index fc2a2241ab..adb08b65d6 100644 --- a/tools/editor/quick_open.cpp +++ b/tools/editor/quick_open.cpp @@ -109,16 +109,16 @@ void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) { } -void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) { +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 +126,26 @@ 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 (list.size() > 0) { + + float this_sim = search_text.to_lower().similarity(path.to_lower()); + float other_sim = search_text.to_lower().similarity(list[0].first.to_lower()); + int pos = 1; + + while (pos < list.size() && this_sim < other_sim) { + other_sim = search_text.to_lower().similarity(list[pos++].first.to_lower()); + } + + pos = this_sim > other_sim ? pos - 1 : pos; + list.insert(pos, pair); + + } else { + list.push_back(pair); + } } } } @@ -138,12 +153,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 (list.size() > 0) { + + float this_sim = search_text.to_lower().similarity(file.to_lower()); + float other_sim = search_text.to_lower().similarity(list[0].first.to_lower()); + int pos = 1; + + while (pos < list.size() && this_sim < other_sim) { + other_sim = search_text.to_lower().similarity(list[pos++].first.to_lower()); + } + + pos = this_sim > other_sim ? pos - 1 : pos; + list.insert(pos, pair); + + } else { + + list.push_back(pair); + } } } @@ -151,7 +183,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 +191,20 @@ 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); + + //String best_match = list[0]; + + 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..45527090b7 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,7 @@ 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); void _confirmed(); diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp index 0df4dfacc1..fa7c898f91 100644 --- a/tools/editor/scenes_dock.cpp +++ b/tools/editor/scenes_dock.cpp @@ -189,6 +189,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")); @@ -663,6 +664,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); @@ -1620,6 +1642,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")); 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(); |