From ef173a2c9cd95e5a72419427c3cb7818b7bf9088 Mon Sep 17 00:00:00 2001 From: romulox_x Date: Wed, 3 Jun 2015 21:57:33 -0700 Subject: [PATCH 1/2] improved calculation of screen resolution on ios --- platform/iphone/gl_view.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 55185aa49d2..3309fd08201 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -352,8 +352,9 @@ static void clear_touches() { // Generate IDs for a framebuffer object and a color renderbuffer UIScreen* mainscr = [UIScreen mainScreen]; printf("******** screen size %i, %i\n", (int)mainscr.currentMode.size.width, (int)mainscr.currentMode.size.height); - if (mainscr.currentMode.size.width == 640 || mainscr.currentMode.size.width == 960) // modern iphone, can go to 640x960 - self.contentScaleFactor = 2.0; + float minPointSize = MIN(mainscr.bounds.size.width, mainscr.bounds.size.height); + float minScreenSize = MIN(mainscr.currentMode.size.width, mainscr.currentMode.size.height); + self.contentScaleFactor = minScreenSize / minPointSize; glGenFramebuffersOES(1, &viewFramebuffer); glGenRenderbuffersOES(1, &viewRenderbuffer); From 9acab32daaea38e09c4d74d5f0340479d3dd41bd Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 6 Jun 2015 09:44:38 -0300 Subject: [PATCH 2/2] new file dialog! -ItemList control for easier lists/thumbnails -New file dialog, with support for thumbnails, favorites, recent places, etc -Moved .fscache out of the project, no more bugs due to committed/pulled .fscache! -Dir dialog now sorts directories --- core/globals.cpp | 7 + core/io/packet_peer.cpp | 21 +- core/io/packet_peer.h | 8 + core/math/math_2d.h | 23 + drivers/gles2/rasterizer_gles2.cpp | 6 +- drivers/gles2/rasterizer_gles2.h | 1 + scene/2d/area_2d.cpp | 39 + scene/2d/area_2d.h | 6 + scene/2d/physics_body_2d.cpp | 39 + scene/2d/physics_body_2d.h | 7 + scene/3d/spatial.cpp | 3 +- scene/gui/item_list.cpp | 1048 +++++++++++++++++ scene/gui/item_list.h | 132 +++ scene/register_scene_types.cpp | 4 +- .../resources/default_theme/default_theme.cpp | 23 +- tools/editor/editor_dir_dialog.cpp | 17 +- tools/editor/editor_file_dialog.cpp | 606 +++++++++- tools/editor/editor_file_dialog.h | 59 +- tools/editor/editor_file_system.cpp | 10 +- tools/editor/editor_resource_preview.cpp | 24 +- tools/editor/editor_resource_preview.h | 4 +- tools/editor/editor_settings.cpp | 90 +- tools/editor/editor_settings.h | 14 + tools/editor/editor_sub_scene.cpp | 4 +- tools/editor/editor_sub_scene.h | 4 +- tools/editor/icons/icon_arrow_left.png | Bin 0 -> 243 bytes .../editor/icons/icon_arrow_left_disabled.png | Bin 0 -> 244 bytes tools/editor/icons/icon_arrow_right.png | Bin 0 -> 263 bytes .../icons/icon_arrow_right_disabled.png | Bin 0 -> 252 bytes tools/editor/icons/icon_arrow_up.png | Bin 0 -> 259 bytes tools/editor/icons/icon_arrow_up_disabled.png | Bin 0 -> 275 bytes tools/editor/icons/icon_favorites.png | Bin 375 -> 412 bytes tools/editor/icons/icon_file_big.png | Bin 0 -> 986 bytes tools/editor/icons/icon_file_list.png | Bin 0 -> 260 bytes tools/editor/icons/icon_file_thumbnail.png | Bin 0 -> 296 bytes tools/editor/icons/icon_folder_big.png | Bin 0 -> 1215 bytes tools/editor/icons/icon_item_list.png | Bin 0 -> 341 bytes tools/editor/icons/icon_remove.png | Bin 398 -> 519 bytes tools/editor/icons/icon_remove_small.png | Bin 0 -> 297 bytes .../io_plugins/editor_font_import_plugin.cpp | 14 +- .../io_plugins/editor_mesh_import_plugin.cpp | 12 +- .../editor_sample_import_plugin.cpp | 12 +- .../io_plugins/editor_scene_import_plugin.cpp | 16 +- .../editor_texture_import_plugin.cpp | 18 +- .../editor_translation_import_plugin.cpp | 10 +- .../animation_player_editor_plugin.cpp | 6 +- .../plugins/animation_player_editor_plugin.h | 2 +- .../plugins/animation_tree_editor_plugin.cpp | 4 +- .../plugins/animation_tree_editor_plugin.h | 2 +- .../plugins/cube_grid_theme_editor_plugin.cpp | 4 +- .../plugins/cube_grid_theme_editor_plugin.h | 2 +- .../plugins/particles_2d_editor_plugin.cpp | 4 +- .../plugins/particles_2d_editor_plugin.h | 2 +- .../plugins/particles_editor_plugin.cpp | 4 +- .../editor/plugins/particles_editor_plugin.h | 2 +- .../resource_preloader_editor_plugin.cpp | 4 +- .../resource_preloader_editor_plugin.h | 2 +- .../plugins/rich_text_editor_plugin.cpp | 4 +- .../editor/plugins/rich_text_editor_plugin.h | 2 +- .../plugins/sample_library_editor_plugin.cpp | 4 +- .../plugins/sample_library_editor_plugin.h | 2 +- .../plugins/sprite_frames_editor_plugin.cpp | 4 +- .../plugins/sprite_frames_editor_plugin.h | 2 +- tools/editor/plugins/theme_editor_plugin.cpp | 6 +- tools/editor/plugins/theme_editor_plugin.h | 2 +- tools/editor/project_export.cpp | 10 +- tools/editor/project_export.h | 6 +- tools/editor/project_settings.cpp | 20 +- tools/editor/project_settings.h | 8 +- tools/editor/property_editor.cpp | 24 +- tools/editor/property_editor.h | 4 +- tools/editor/scene_tree_dock.cpp | 6 +- tools/editor/scene_tree_dock.h | 2 +- tools/editor/script_create_dialog.cpp | 4 +- tools/editor/script_create_dialog.h | 4 +- 75 files changed, 2219 insertions(+), 214 deletions(-) create mode 100644 scene/gui/item_list.cpp create mode 100644 scene/gui/item_list.h create mode 100644 tools/editor/icons/icon_arrow_left.png create mode 100644 tools/editor/icons/icon_arrow_left_disabled.png create mode 100644 tools/editor/icons/icon_arrow_right.png create mode 100644 tools/editor/icons/icon_arrow_right_disabled.png create mode 100644 tools/editor/icons/icon_arrow_up.png create mode 100644 tools/editor/icons/icon_arrow_up_disabled.png create mode 100644 tools/editor/icons/icon_file_big.png create mode 100644 tools/editor/icons/icon_file_list.png create mode 100644 tools/editor/icons/icon_file_thumbnail.png create mode 100644 tools/editor/icons/icon_folder_big.png create mode 100644 tools/editor/icons/icon_item_list.png create mode 100644 tools/editor/icons/icon_remove_small.png diff --git a/core/globals.cpp b/core/globals.cpp index 0315ff0c24c..8a7d66b68af 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -1396,6 +1396,13 @@ Globals::Globals() { va.push_back(joyb); set("input/ui_accept",va); + va=Array(); + key.key.scancode=KEY_SPACE; + va.push_back(key); + joyb.joy_button.button_index=JOY_BUTTON_3; + va.push_back(joyb); + set("input/ui_select",va); + va=Array(); key.key.scancode=KEY_ESCAPE; va.push_back(key); diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 7b5ea65a4bc..be566471a85 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -36,7 +36,7 @@ PacketPeer::PacketPeer() { - + last_get_error=OK; } Error PacketPeer::get_packet_buffer(DVector &r_buffer) const { @@ -108,10 +108,29 @@ Variant PacketPeer::_bnd_get_var() const { return var; }; +Error PacketPeer::_put_packet(const DVector &p_buffer) { + return put_packet_buffer(p_buffer); +} +DVector PacketPeer::_get_packet() const { + + DVector raw; + last_get_error=get_packet_buffer(raw); + return raw; +} + +Error PacketPeer::_get_packet_error() const { + + return last_get_error; +} + + void PacketPeer::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_var"),&PacketPeer::_bnd_get_var); ObjectTypeDB::bind_method(_MD("put_var", "var:var"),&PacketPeer::put_var); + ObjectTypeDB::bind_method(_MD("get_packet:Error"),&PacketPeer::_get_packet); + ObjectTypeDB::bind_method(_MD("put_packet", "buffer"),&PacketPeer::_get_packet); + ObjectTypeDB::bind_method(_MD("get_packet_error:Error"),&PacketPeer::_get_packet_error); ObjectTypeDB::bind_method(_MD("get_available_packet_count"),&PacketPeer::get_available_packet_count); }; diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h index 3448ebde1b8..76d1eb22b57 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -41,6 +41,14 @@ class PacketPeer : public Reference { static void _bind_methods(); + + Error _put_packet(const DVector &p_buffer); + DVector _get_packet() const; + Error _get_packet_error() const; + + + mutable Error last_get_error; + public: virtual int get_available_packet_count() const=0; diff --git a/core/math/math_2d.h b/core/math/math_2d.h index ac315fddb75..5e6cefd114d 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -226,6 +226,29 @@ struct Rect2 { return true; } + inline float distance_to(const Vector2& p_point) const { + + float dist = 1e20; + + if (p_point.x < pos.x) { + dist=MIN(dist,pos.x-p_point.x); + } + if (p_point.y < pos.y) { + dist=MIN(dist,pos.y-p_point.y); + } + if (p_point.x >= (pos.x+size.x) ) { + dist=MIN(p_point.x-(pos.x+size.x),dist); + } + if (p_point.y >= (pos.y+size.y) ) { + dist=MIN(p_point.y-(pos.y+size.y),dist); + } + + if (dist==1e20) + return 0; + else + return dist; + } + _FORCE_INLINE_ bool intersects_transformed(const Matrix32& p_xform, const Rect2& p_rect) const; bool intersects_segment(const Point2& p_from, const Point2& p_to, Point2* r_pos=NULL, Point2* r_normal=NULL) const; diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 4acac957c84..a588643fd97 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -5214,7 +5214,7 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material DEBUG_TEST_ERROR("Material arameters"); if (p_material->shader_cache->uses_time) { - material_shader.set_uniform(MaterialShaderGLES2::TIME,Math::fmod(last_time,300.0)); + material_shader.set_uniform(MaterialShaderGLES2::TIME,Math::fmod(last_time,shader_time_rollback)); draw_next_frame=true; } //if uses TIME - draw_next_frame=true @@ -9219,7 +9219,7 @@ void RasterizerGLES2::_canvas_item_setup_shader_uniforms(CanvasItemMaterial *mat } if (shader->uses_time) { - canvas_shader.set_uniform(CanvasShaderGLES2::TIME,Math::fmod(last_time,300.0)); + canvas_shader.set_uniform(CanvasShaderGLES2::TIME,Math::fmod(last_time,shader_time_rollback)); draw_next_frame=true; } //if uses TIME - draw_next_frame=true @@ -10814,6 +10814,8 @@ void RasterizerGLES2::init() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);// unbind #endif + shader_time_rollback = GLOBAL_DEF("rasterizer/shader_time_rollback",300); + using_canvas_bg=false; _update_framebuffer(); DEBUG_TEST_ERROR("Initializing"); diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index 1821b1a7503..e83bd39caa1 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -1273,6 +1273,7 @@ class RasterizerGLES2 : public Rasterizer { Environment *current_env; VS::ScenarioDebugMode current_debug; RID overdraw_material; + float shader_time_rollback; mutable MaterialShaderGLES2 material_shader; diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 827256c2fa5..e30333377f2 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -535,6 +535,39 @@ uint32_t Area2D::get_layer_mask() const { return layer_mask; } +void Area2D::set_collision_mask_bit(int p_bit, bool p_value) { + + uint32_t mask = get_collision_mask(); + if (p_value) + mask|=1<body_create(p_mode), false) { diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 03f95959b67..b70fdd59cf3 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -61,6 +61,13 @@ public: void set_collision_mask(uint32_t p_mask); uint32_t get_collision_mask() const; + + void set_collision_mask_bit(int p_bit, bool p_value); + bool get_collision_mask_bit(int p_bit) const; + + void set_layer_mask_bit(int p_bit, bool p_value); + bool get_layer_mask_bit(int p_bit) const; + void add_collision_exception_with(Node* p_node); //must be physicsbody void remove_collision_exception_with(Node* p_node); diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 9c69520a85b..c672d0e94f2 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -626,10 +626,11 @@ void Spatial::rotate_z(float p_radians){ void Spatial::translate(const Vector3& p_offset){ Transform t =get_transform(); - t.origin+=p_offset; + t.translate(p_offset); set_transform(t); } + void Spatial::scale(const Vector3& p_ratio){ Transform t =get_transform(); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp new file mode 100644 index 00000000000..2fd4d810de0 --- /dev/null +++ b/scene/gui/item_list.cpp @@ -0,0 +1,1048 @@ +#include "item_list.h" +#include "os/os.h" +#include "globals.h" + + +void ItemList::add_item(const String& p_item,const Ref& p_texture,bool p_selectable) { + + Item item; + item.icon=p_texture; + item.text=p_item; + item.selectable=p_selectable; + item.selected=false; + item.disabled=false; + items.push_back(item); + + update(); + shape_changed=true; + +} + +void ItemList::add_icon_item(const Ref& p_item,bool p_selectable){ + + Item item; + item.icon=p_item; + //item.text=p_item; + item.selectable=p_selectable; + item.selected=false; + item.disabled=false; + items.push_back(item); + + update(); + shape_changed=true; + +} + +void ItemList::set_item_text(int p_idx,const String& p_text){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].text=p_text; + update(); + shape_changed=true; + +} + +String ItemList::get_item_text(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),String()); + return items[p_idx].text; + +} + +void ItemList::set_item_tooltip(int p_idx,const String& p_tooltip){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].tooltip=p_tooltip; + update(); + shape_changed=true; + +} + +String ItemList::get_item_tooltip(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),String()); + return items[p_idx].tooltip; + +} + +void ItemList::set_item_icon(int p_idx,const Ref& p_icon){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].icon=p_icon; + update(); + shape_changed=true; + + +} +Ref ItemList::get_item_icon(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),Ref()); + + return items[p_idx].icon; + +} + + +void ItemList::set_item_tag_icon(int p_idx,const Ref& p_tag_icon){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].tag_icon=p_tag_icon; + update(); + shape_changed=true; + + +} +Ref ItemList::get_item_tag_icon(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),Ref()); + + return items[p_idx].tag_icon; + +} + +void ItemList::set_item_selectable(int p_idx,bool p_selectable){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].selectable=p_selectable; + + +} + + +bool ItemList::is_item_selectable(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),false); + return items[p_idx].selectable; +} + +void ItemList::set_item_disabled(int p_idx,bool p_disabled){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].disabled=p_disabled; + + +} + + +bool ItemList::is_item_disabled(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),false); + return items[p_idx].disabled; +} + + +void ItemList::set_item_metadata(int p_idx,const Variant& p_metadata){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].metadata=p_metadata; + update(); + shape_changed=true; + +} + +Variant ItemList::get_item_metadata(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),Variant()); + return items[p_idx].metadata; + +} +void ItemList::select(int p_idx,bool p_single){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + if (p_single || select_mode==SELECT_SINGLE) { + + if (!items[p_idx].selectable) { + return; + } + + for(int i=0;i bg = get_stylebox("bg"); + pos-=bg->get_offset(); + pos.y+=scroll_bar->get_val(); + + int closest = -1; + int closest_dist=0x7FFFFFFF; + + for(int i=0;i=0 && currentset_val( scroll_bar->get_val()-scroll_bar->get_page()/8 ); + + } + if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_DOWN && p_event.mouse_button.pressed) { + + scroll_bar->set_val( scroll_bar->get_val()+scroll_bar->get_page()/8 ); + + } + + if (p_event.is_pressed() && items.size()>0) { + if (p_event.is_action("ui_up")) { + + if (search_string!="") { + + uint64_t now = OS::get_singleton()->get_ticks_msec(); + uint64_t diff = now-search_time_msec; + + if (diffget("gui/incr_search_max_interval_msec"))*2) { + + for(int i=current-1;i>=0;i--) { + + if (items[i].text.begins_with(search_string)) { + + set_current(i); + ensure_current_is_visible(); + if (select_mode==SELECT_SINGLE) { + emit_signal("item_selected",current); + } + + + break; + } + } + accept_event(); + return; + } + } + + if (current>=current_columns) { + set_current(current-current_columns); + ensure_current_is_visible(); + if (select_mode==SELECT_SINGLE) { + emit_signal("item_selected",current); + } + accept_event(); + } + } else if (p_event.is_action("ui_down")) { + + if (search_string!="") { + + uint64_t now = OS::get_singleton()->get_ticks_msec(); + uint64_t diff = now-search_time_msec; + + if (diffget("gui/incr_search_max_interval_msec"))*2) { + + for(int i=current+1;i0;i--) { + if (current-current_columns*i >=0 ) { + set_current( current- current_columns*i); + ensure_current_is_visible(); + if (select_mode==SELECT_SINGLE) { + emit_signal("item_selected",current); + } + accept_event(); + break; + } + } + } else if (p_event.is_action("ui_page_down")) { + + search_string=""; //any mousepress cancels + + for(int i=4;i>0;i--) { + if (current+current_columns*i < items.size() ) { + set_current( current+ current_columns*i); + ensure_current_is_visible(); + if (select_mode==SELECT_SINGLE) { + emit_signal("item_selected",current); + } + accept_event(); + + break; + } + } + } else if (p_event.is_action("ui_left")) { + + search_string=""; //any mousepress cancels + + if (current%current_columns!=0) { + set_current(current-1); + ensure_current_is_visible(); + if (select_mode==SELECT_SINGLE) { + emit_signal("item_selected",current); + } + accept_event(); + + } + } else if (p_event.is_action("ui_right")) { + + search_string=""; //any mousepress cancels + + if (current%current_columns!=(current_columns-1)) { + set_current(current+1); + ensure_current_is_visible(); + if (select_mode==SELECT_SINGLE) { + emit_signal("item_selected",current); + } + accept_event(); + + } + } else if (p_event.is_action("ui_cancel")) { + search_string=""; + } else if (p_event.is_action("ui_select")) { + + + if (select_mode==SELECT_MULTI && current>=0 && current=0 && currentget_ticks_msec(); + uint64_t diff = now-search_time_msec; + uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000)); + search_time_msec = now; + + if (diff>max_interval) { + search_string=""; + } + + search_string+=String::chr(p_event.key.unicode); + for(int i=0;i=0 && current <=items.size()) { + + Rect2 r = items[current].rect_cache; + int from = scroll_bar->get_val(); + int to = from + scroll_bar->get_page(); + + if (r.pos.y < from) { + scroll_bar->set_val(r.pos.y); + } else if (r.pos.y+r.size.y > to) { + scroll_bar->set_val(r.pos.y+r.size.y - (to-from)); + } + } +} + +void ItemList::_notification(int p_what) { + + if (p_what==NOTIFICATION_RESIZED) { + shape_changed=true; + update(); + } + + if (p_what==NOTIFICATION_DRAW) { + + VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true); + Ref bg = get_stylebox("bg"); + + int mw = scroll_bar->get_minimum_size().x; + scroll_bar->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,mw+bg->get_margin(MARGIN_RIGHT)); + scroll_bar->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,bg->get_margin(MARGIN_RIGHT)); + scroll_bar->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,bg->get_margin(MARGIN_TOP)); + scroll_bar->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,bg->get_margin(MARGIN_BOTTOM)); + + + Size2 size = get_size(); + + float page = size.height-bg->get_minimum_size().height; + int width = size.width - mw - bg->get_minimum_size().width; + scroll_bar->set_page(page); + + draw_style_box(bg,Rect2(Point2(),size)); + + int hseparation = get_constant("hseparation"); + int vseparation = get_constant("vseparation"); + int icon_margin = get_constant("icon_margin"); + int line_separation = get_constant("line_separation"); + + Ref sbsel = has_focus()?get_stylebox("selected_focus"):get_stylebox("selected"); + Ref cursor = has_focus()?get_stylebox("cursor"):get_stylebox("cursor_unfocused"); + + Ref font = get_font("font"); + Color guide_color = get_color("guide_color"); + Color font_color = get_color("font_color"); + int font_height = font->get_height(); + Vector line_size_cache; + Vector line_limit_cache; + + if (max_text_lines) { + line_size_cache.resize(max_text_lines); + line_limit_cache.resize(max_text_lines); + } + + if (has_focus()) { + VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(),true); + draw_style_box(get_stylebox("bg_focus"),Rect2(Point2(),size)); + VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(),false); + } + + if (shape_changed) { + + //1- compute item minimum sizes + for(int i=0;iget_size(); + if (min_icon_size.x!=0) + minsize.x = MAX(minsize.x,min_icon_size.x); + if (min_icon_size.y!=0) + minsize.y = MAX(minsize.y,min_icon_size.y); + + if (items[i].text!="") { + if (icon_mode==ICON_MODE_TOP) { + minsize.y+=icon_margin; + } else { + minsize.x+=icon_margin; + } + } + } + + if (items[i].text!="") { + + Size2 s = font->get_string_size(items[i].text); + //s.width=MIN(s.width,fixed_column_width); + + + + if (icon_mode==ICON_MODE_TOP) { + minsize.x=MAX(minsize.x,s.width); + if (max_text_lines>0) { + minsize.y+=(font_height+line_separation)*max_text_lines; + } else { + minsize.y+=s.height; + } + + } else { + minsize.y=MAX(minsize.y,s.height); + minsize.x+=s.width; + } + } + + + + items[i].rect_cache.size=minsize; + if (fixed_column_width>0) + items[i].rect_cache.size.x=fixed_column_width; + + } + + int fit_size = size.x - bg->get_minimum_size().width - mw; + + //2-attempt best fit + current_columns = 0x7FFFFFFF; + if (max_columns>0) + current_columns=max_columns; + + + while(true) { + //repeat util all fits + //print_line("try with "+itos(current_columns)); + bool all_fit=true; + Vector2 ofs; + int col=0; + int max_h=0; + separators.clear();; + for(int i=0;i1 && items[i].rect_cache.size.width+ofs.x > fit_size) { + //went past + current_columns=MAX(col,1); + all_fit=false; + break; + } + + items[i].rect_cache.pos=ofs; + max_h=MAX(max_h,items[i].rect_cache.size.y); + ofs.x+=items[i].rect_cache.size.x; + //print_line("item "+itos(i)+" ofs "+rtos(items[i].rect_cache.size.x)); + if (col>0) + ofs.x+=hseparation; + col++; + if (col==current_columns) { + + if (iset_max(max); + //print_line("max: "+rtos(max)+" page "+rtos(page)); + if (max<=page) { + scroll_bar->set_val(0); + scroll_bar->hide(); + } else { + scroll_bar->show(); + } + break; + } + } + + + shape_changed=false; + } + + + + Vector2 base_ofs = bg->get_offset(); + base_ofs.y-=int(scroll_bar->get_val()); + + Rect2 clip(Point2(),size-bg->get_minimum_size()+Vector2(0,scroll_bar->get_val())); + + for(int i=0;iget_margin(MARGIN_LEFT); + r.size.x+=sbsel->get_margin(MARGIN_LEFT)+sbsel->get_margin(MARGIN_RIGHT); + r.pos.y-=sbsel->get_margin(MARGIN_TOP); + r.size.y+=sbsel->get_margin(MARGIN_TOP)+sbsel->get_margin(MARGIN_BOTTOM); + + draw_style_box(sbsel,r); + + } + + + Vector2 text_ofs; + if (items[i].icon.is_valid()) { + + Vector2 icon_ofs; + if (min_icon_size!=Vector2()) { + icon_ofs = (min_icon_size - items[i].icon->get_size())/2; + } + + if (icon_mode==ICON_MODE_TOP) { + draw_texture(items[i].icon,icon_ofs+items[i].rect_cache.pos+Vector2(items[i].rect_cache.size.width/2-items[i].icon->get_width()/2,0).floor()+base_ofs); + text_ofs.y = MAX(items[i].icon->get_height(),min_icon_size.y)+icon_margin; + } else { + draw_texture(items[i].icon,icon_ofs+items[i].rect_cache.pos+Vector2(0,items[i].rect_cache.size.height/2-items[i].icon->get_height()/2).floor()+base_ofs); + text_ofs.x = MAX(items[i].icon->get_width(),min_icon_size.x)+icon_margin; + } + } + + if (items[i].tag_icon.is_valid()) { + + draw_texture(items[i].tag_icon,items[i].rect_cache.pos+base_ofs); + } + + if (items[i].text!="") { + + int max_len=-1; + + Vector2 size = font->get_string_size(items[i].text); + if (fixed_column_width) + max_len=fixed_column_width; + else + max_len=size.x; + + if (icon_mode==ICON_MODE_TOP && max_text_lines>0) { + + int ss = items[i].text.length(); + float ofs=0; + int line=0; + for(int j=0;j<=ss;j++) { + + int cs = jget_char_size(items[i].text[j],items[i].text[j+1]).x:0; + if (ofs+cs>max_len || j==ss) { + line_limit_cache[line]=j; + line_size_cache[line]=ofs; + line++; + ofs=0; + if (line>=max_text_lines) + break; + } else { + ofs+=cs; + } + + } + + line=0; + ofs=0; + + text_ofs.y+=font->get_ascent(); + text_ofs=text_ofs.floor(); + text_ofs+=base_ofs; + text_ofs+=items[i].rect_cache.pos; + + for(int j=0;j=max_text_lines) + break; + } + ofs+=font->draw_char(get_canvas_item(),text_ofs+Vector2(ofs+(max_len-line_size_cache[line])/2,line*(font_height+line_separation)).floor(),items[i].text[j],items[i].text[j+1],font_color); + } + + //special multiline mode + } else { + + if (fixed_column_width>0) + size.x=MIN(size.x,fixed_column_width); + + if (icon_mode==ICON_MODE_TOP) { + text_ofs.x+=(items[i].rect_cache.size.width-size.x)/2; + } else { + text_ofs.y+=(items[i].rect_cache.size.height-size.y)/2; + } + + text_ofs.y+=font->get_ascent(); + text_ofs=text_ofs.floor(); + text_ofs+=base_ofs; + text_ofs+=items[i].rect_cache.pos; + + draw_string(font,text_ofs,items[i].text,font_color,max_len+1); + } + + + } + + if (select_mode==SELECT_MULTI && i==current) { + + Rect2 r=rcache; + r.pos+=base_ofs; + draw_style_box(cursor,r); + + } + } + + for(int i=0;iget_margin(MARGIN_LEFT),base_ofs.y+separators[i]),Vector2(size.width-bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),guide_color); + } + + } +} + +void ItemList::_scroll_changed(double) { + update(); +} + + +String ItemList::get_tooltip(const Point2& p_pos) const { + + Vector2 pos=p_pos; + Ref bg = get_stylebox("bg"); + pos-=bg->get_offset(); + pos.y+=scroll_bar->get_val(); + + int closest = -1; + int closest_dist=0x7FFFFFFF; + + for(int i=0;i()),DEFVAL(true)); + ObjectTypeDB::bind_method(_MD("add_icon_item","icon:Texture","selectable"),&ItemList::add_icon_item,DEFVAL(true)); + + ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&ItemList::set_item_text); + ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&ItemList::get_item_text); + + ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon); + ObjectTypeDB::bind_method(_MD("get_item_icon:Tedture","idx"),&ItemList::get_item_icon); + + ObjectTypeDB::bind_method(_MD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable); + ObjectTypeDB::bind_method(_MD("is_item_selectable","idx"),&ItemList::is_item_selectable); + + ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&ItemList::set_item_disabled); + ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&ItemList::is_item_disabled); + + ObjectTypeDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&ItemList::set_item_tooltip); + ObjectTypeDB::bind_method(_MD("get_item_tooltip","idx"),&ItemList::get_item_tooltip); + + ObjectTypeDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true)); + ObjectTypeDB::bind_method(_MD("unselect","idx"),&ItemList::unselect); + ObjectTypeDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected); + + ObjectTypeDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count); + ObjectTypeDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item); + + ObjectTypeDB::bind_method(_MD("clear"),&ItemList::clear); + + ObjectTypeDB::bind_method(_MD("set_fixed_column_width","width"),&ItemList::set_fixed_column_width); + ObjectTypeDB::bind_method(_MD("get_fixed_column_width"),&ItemList::get_fixed_column_width); + + ObjectTypeDB::bind_method(_MD("set_max_text_lines","lines"),&ItemList::set_max_text_lines); + ObjectTypeDB::bind_method(_MD("get_max_text_lines"),&ItemList::get_max_text_lines); + + ObjectTypeDB::bind_method(_MD("set_max_columns","amount"),&ItemList::set_max_columns); + ObjectTypeDB::bind_method(_MD("get_max_columns"),&ItemList::get_max_columns); + + ObjectTypeDB::bind_method(_MD("set_select_mode","mode"),&ItemList::set_select_mode); + ObjectTypeDB::bind_method(_MD("get_select_mode"),&ItemList::get_select_mode); + + ObjectTypeDB::bind_method(_MD("set_icon_mode","mode"),&ItemList::set_icon_mode); + ObjectTypeDB::bind_method(_MD("get_icon_mode"),&ItemList::get_icon_mode); + + ObjectTypeDB::bind_method(_MD("set_min_icon_size","size"),&ItemList::set_min_icon_size); + ObjectTypeDB::bind_method(_MD("get_min_icon_size"),&ItemList::get_min_icon_size); + + ObjectTypeDB::bind_method(_MD("ensure_current_is_visible"),&ItemList::ensure_current_is_visible); + + ObjectTypeDB::bind_method(_MD("_scroll_changed"),&ItemList::_scroll_changed); + ObjectTypeDB::bind_method(_MD("_input_event"),&ItemList::_input_event); + + BIND_CONSTANT( ICON_MODE_TOP ); + BIND_CONSTANT( ICON_MODE_LEFT ); + BIND_CONSTANT( SELECT_SINGLE ); + BIND_CONSTANT( SELECT_MULTI ); + + ADD_SIGNAL( MethodInfo("item_selected",PropertyInfo(Variant::INT,"index"))); + ADD_SIGNAL( MethodInfo("multi_selected",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::BOOL,"selected"))); + ADD_SIGNAL( MethodInfo("item_activated",PropertyInfo(Variant::INT,"index"))); +} + + + +ItemList::ItemList() { + + current=-1; + + select_mode=SELECT_SINGLE; + icon_mode=ICON_MODE_LEFT; + + fixed_column_width=0; + max_text_lines=1; + max_columns=1; + + scroll_bar = memnew( VScrollBar ); + add_child(scroll_bar); + + shape_changed=true; + scroll_bar->connect("value_changed",this,"_scroll_changed"); + + set_focus_mode(FOCUS_ALL); + current_columns=1; + search_time_msec=0; + +} + +ItemList::~ItemList() { + +} + diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h new file mode 100644 index 00000000000..6bbb416970c --- /dev/null +++ b/scene/gui/item_list.h @@ -0,0 +1,132 @@ +#ifndef ITEMLIST_H +#define ITEMLIST_H + +#include "scene/gui/control.h" +#include "scene/gui/scroll_bar.h" + +class ItemList : public Control { + + OBJ_TYPE( ItemList, Control ); +public: + + enum IconMode { + ICON_MODE_TOP, + ICON_MODE_LEFT + }; + + enum SelectMode { + SELECT_SINGLE, + SELECT_MULTI + }; +private: + struct Item { + + Ref icon; + Ref tag_icon; + String text; + bool selectable; + bool selected; + bool disabled; + Variant metadata; + String tooltip; + + Rect2 rect_cache; + }; + + int current; + + bool shape_changed; + + Vector items; + Vector separators; + + SelectMode select_mode; + IconMode icon_mode; + VScrollBar *scroll_bar; + + uint64_t search_time_msec; + String search_string; + + int current_columns; + int fixed_column_width; + int max_text_lines; + int max_columns; + Size2 min_icon_size; + + void _scroll_changed(double); + void _input_event(const InputEvent& p_event); +protected: + + void _notification(int p_what); + static void _bind_methods(); +public: + + void add_item(const String& p_item,const Ref& p_texture=Ref(),bool p_selectable=true); + void add_icon_item(const Ref& p_item,bool p_selectable=true); + + void set_item_text(int p_idx,const String& p_text); + String get_item_text(int p_idx) const; + + void set_item_icon(int p_idx,const Ref& p_icon); + Ref get_item_icon(int p_idx) const; + + void set_item_selectable(int p_idx,bool p_selectable); + bool is_item_selectable(int p_idx) const; + + void set_item_disabled(int p_idx,bool p_disabled); + bool is_item_disabled(int p_idx) const; + + void set_item_metadata(int p_idx,const Variant& p_metadata); + Variant get_item_metadata(int p_idx) const; + + void set_item_tag_icon(int p_idx,const Ref& p_tag_icon); + Ref get_item_tag_icon(int p_idx) const; + + void set_item_tooltip(int p_idx,const String& p_tooltip); + String get_item_tooltip(int p_idx) const; + + void select(int p_idx,bool p_single=true); + void unselect(int p_idx); + bool is_selected(int p_idx) const; + + void set_current(int p_current); + int get_current() const; + + + int get_item_count() const; + void remove_item(int p_idx); + + void clear(); + + void set_fixed_column_width(int p_size); + int get_fixed_column_width() const; + + void set_max_text_lines(int p_amount); + int get_max_text_lines() const; + + void set_max_columns(int p_amount); + int get_max_columns() const; + + void set_select_mode(SelectMode p_mode); + SelectMode get_select_mode() const; + + void set_icon_mode(IconMode p_mode); + IconMode get_icon_mode() const; + + void set_min_icon_size(const Size2& p_size); + Size2 get_min_icon_size() const; + + void ensure_current_is_visible(); + + + virtual String get_tooltip(const Point2& p_pos) const; + + ItemList(); + ~ItemList(); +}; + +VARIANT_ENUM_CAST(ItemList::SelectMode); +VARIANT_ENUM_CAST(ItemList::IconMode); + + +#endif // ITEMLIST_H diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 687410d1926..f78481b7453 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -66,6 +66,7 @@ #include "scene/gui/file_dialog.h" #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" +#include "scene/gui/item_list.h" #include "scene/gui/text_edit.h" #include "scene/gui/texture_button.h" #include "scene/gui/separator.h" @@ -327,7 +328,7 @@ void register_scene_types() { ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); - + ObjectTypeDB::register_type(); #ifndef ADVANCED_GUI_DISABLED @@ -335,6 +336,7 @@ void register_scene_types() { ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); + ObjectTypeDB::register_type(); ObjectTypeDB::register_virtual_type(); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index d43ffd21301..62fa01f5877 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -574,7 +574,7 @@ void make_default_theme() { // Tree Ref tree_selected = make_stylebox( selection_png,4,4,4,4,8,0,8,0); - Ref tree_selected_oof = make_stylebox( selection_oof_png,4,4,4,4,8,0,8,0); + Ref tree_selected_oof = make_stylebox( selection_oof_png,4,4,4,4,8,0,8,0); t->set_stylebox("bg","Tree", make_stylebox( tree_bg_png,4,4,4,5) ); t->set_stylebox("bg_focus","Tree", focus ); @@ -605,12 +605,31 @@ void make_default_theme() { t->set_color("guide_color","Tree", Color(0,0,0,0.1) ); t->set_constant("hseparation","Tree",4); - t->set_constant("vseparation","Tree",2); + t->set_constant("vseparation","Tree",4); t->set_constant("guide_width","Tree",2); t->set_constant("item_margin","Tree",12); t->set_constant("button_margin","Tree",4); + // ItemList + Ref item_selected = make_stylebox( selection_png,4,4,4,4,8,2,8,2); + Ref item_selected_oof = make_stylebox( selection_oof_png,4,4,4,4,8,2,8,2); + + t->set_stylebox("bg","ItemList", make_stylebox( tree_bg_png,4,4,4,5) ); + t->set_stylebox("bg_focus","ItemList", focus ); + t->set_constant("hseparation","ItemList",4); + t->set_constant("vseparation","ItemList",2); + t->set_constant("icon_margin","ItemList",4); + t->set_constant("line_separation","ItemList",2); + t->set_font("font","ItemList", default_font ); + t->set_color("font_color","ItemList", control_font_color_low ); + t->set_color("font_color_selected","ItemList", control_font_color_pressed ); + t->set_color("guide_color","ItemList", Color(0,0,0,0.1) ); + t->set_stylebox("selected","ItemList", item_selected_oof ); + t->set_stylebox("selected_focus","ItemList", item_selected ); + t->set_stylebox("cursor","ItemList", focus ); + t->set_stylebox("cursor_unfocused","ItemList", focus ); + // TextEdit diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp index 5e6bad41aa9..a8421acff86 100644 --- a/tools/editor/editor_dir_dialog.cpp +++ b/tools/editor/editor_dir_dialog.cpp @@ -43,6 +43,7 @@ void EditorDirDialog::_update_dir(TreeItem* p_item) { da->list_dir_begin(); String p=da->get_next(); + List dirs; bool ishidden; bool show_hidden = EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"); @@ -52,16 +53,22 @@ void EditorDirDialog::_update_dir(TreeItem* p_item) { if (show_hidden || !ishidden) { if (da->current_is_dir() && !p.begins_with(".")) { - TreeItem *ti = tree->create_item(p_item); - ti->set_text(0,p); - ti->set_icon(0,get_icon("Folder","EditorIcons")); - ti->set_collapsed(true); + dirs.push_back(p); } } - p=da->get_next(); } + dirs.sort(); + + for(List::Element *E=dirs.front();E;E=E->next()) { + TreeItem *ti = tree->create_item(p_item); + ti->set_text(0,E->get()); + ti->set_icon(0,get_icon("Folder","EditorIcons")); + ti->set_collapsed(true); + + } + memdelete(da); updating=false; diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index 359f807ae4b..e3508e4493b 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -4,8 +4,8 @@ #include "print_string.h" #include "os/keyboard.h" #include "editor_resource_preview.h" - - +#include "editor_settings.h" +#include "scene/gui/margin_container.h" EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func=NULL; EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func=NULL; @@ -19,6 +19,21 @@ VBoxContainer *EditorFileDialog::get_vbox() { } void EditorFileDialog::_notification(int p_what) { + + if (p_what==NOTIFICATION_ENTER_TREE) { + + mode_thumbnails->set_icon(get_icon("FileThumbnail","EditorIcons")); + mode_list->set_icon(get_icon("FileList","EditorIcons")); + dir_prev->set_icon(get_icon("ArrowLeft","EditorIcons")); + dir_next->set_icon(get_icon("ArrowRight","EditorIcons")); + dir_up->set_icon(get_icon("ArrowUp","EditorIcons")); + favorite->set_icon(get_icon("Favorites","EditorIcons")); + + fav_up->set_icon(get_icon("MoveUp","EditorIcons")); + fav_down->set_icon(get_icon("MoveDown","EditorIcons")); + fav_rm->set_icon(get_icon("RemoveSmall","EditorIcons")); + + } if (p_what==NOTIFICATION_PROCESS) { if (preview_waiting) { @@ -43,20 +58,19 @@ void EditorFileDialog::_notification(int p_what) { void EditorFileDialog::set_enable_multiple_selection(bool p_enable) { - tree->set_select_mode(p_enable?Tree::SELECT_MULTI : Tree::SELECT_SINGLE); + item_list->set_select_mode(p_enable?ItemList::SELECT_MULTI:ItemList::SELECT_SINGLE); + }; Vector EditorFileDialog::get_selected_files() const { Vector list; - - TreeItem* item = tree->get_root(); - while ( (item = tree->get_next_selected(item)) ) { - - list.push_back(dir_access->get_current_dir().plus_file(item->get_text(0))); - }; - + for(int i=0;iget_item_count();i++) { + if (item_list->is_selected(i)) + list.push_back(item_list->get_item_text(i)); + } return list; + }; void EditorFileDialog::update_dir() { @@ -71,6 +85,9 @@ void EditorFileDialog::_dir_entered(String p_dir) { file->set_text(""); invalidate(); update_dir(); + _push_history(); + + } void EditorFileDialog::_file_entered(const String& p_file) { @@ -80,6 +97,7 @@ void EditorFileDialog::_file_entered(const String& p_file) { void EditorFileDialog::_save_confirm_pressed() { String f=dir_access->get_current_dir().plus_file(file->get_text()); + _save_to_recent(); emit_signal("file_selected",f); hide(); } @@ -94,11 +112,56 @@ void EditorFileDialog::_post_popup() { if (mode==MODE_SAVE_FILE) file->grab_focus(); else - tree->grab_focus(); + item_list->grab_focus(); if (is_visible() && get_current_file()!="") _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + if (is_visible()) { + Ref folder = get_icon("folder","FileDialog"); + recent->clear(); + + + bool res = access==ACCESS_RESOURCES; + Vector recentd = EditorSettings::get_singleton()->get_recent_dirs(); + for(int i=0;iadd_item(name,folder); + recent->set_item_metadata( recent->get_item_count()-1,recentd[i]); + } + + local_history.clear(); + local_history_pos=-1; + _push_history(); + + _update_favorites(); + } + +} + +void EditorFileDialog::_thumbnail_result(const String& p_path,const Ref& p_preview, const Variant& p_udata) { + + if (display_mode==DISPLAY_LIST || p_preview.is_null()) + return; + + for(int i=0;iget_item_count();i++) { + Dictionary d = item_list->get_item_metadata(i); + String pname = d["path"]; + if (pname==p_path) { + item_list->set_item_icon(i,p_preview); + item_list->set_item_tag_icon(i,Ref()); + } + } } void EditorFileDialog::_thumbnail_done(const String& p_path,const Ref& p_preview, const Variant& p_udata) { @@ -108,8 +171,13 @@ void EditorFileDialog::_thumbnail_done(const String& p_path,const Ref& if (p_preview.is_valid() && get_current_path()==p_path) { + preview->set_texture(p_preview); - preview_vb->show(); + if (display_mode==DISPLAY_THUMBNAILS) { + preview_vb->hide(); + } else { + preview_vb->show(); + } } else { preview_vb->hide(); @@ -133,17 +201,17 @@ void EditorFileDialog::_action_pressed() { if (mode==MODE_OPEN_FILES) { - TreeItem *ti=tree->get_next_selected(NULL); + String fbase=dir_access->get_current_dir(); DVector files; - while(ti) { - - files.push_back( fbase.plus_file(ti->get_text(0)) ); - ti=tree->get_next_selected(ti); + for(int i=0;iget_item_count();i++) { + if (item_list->is_selected(i)) + files.push_back( fbase.plus_file(item_list->get_item_text(i) )); } if (files.size()) { + _save_to_recent(); emit_signal("files_selected",files); hide(); } @@ -154,6 +222,7 @@ void EditorFileDialog::_action_pressed() { String f=dir_access->get_current_dir().plus_file(file->get_text()); if (mode==MODE_OPEN_FILE && dir_access->file_exists(f)) { + _save_to_recent(); emit_signal("file_selected",f); hide(); } @@ -169,6 +238,7 @@ void EditorFileDialog::_action_pressed() { } }*/ path=path.replace("\\","/"); + _save_to_recent(); emit_signal("dir_selected",path); hide(); } @@ -237,7 +307,7 @@ void EditorFileDialog::_action_pressed() { confirm_save->popup_centered(Size2(200,80)); } else { - + _save_to_recent(); emit_signal("file_selected",f); hide(); } @@ -251,12 +321,13 @@ void EditorFileDialog::_cancel_pressed() { hide(); } -void EditorFileDialog::_tree_selected() { +void EditorFileDialog::_item_selected(int p_item) { - TreeItem *ti=tree->get_selected(); - if (!ti) + int current = p_item; + if (current<0 || current>=item_list->get_item_count()) return; - Dictionary d=ti->get_metadata(0); + + Dictionary d=item_list->get_item_metadata(current); if (!d["dir"]) { @@ -265,34 +336,105 @@ void EditorFileDialog::_tree_selected() { } } -void EditorFileDialog::_tree_dc_selected() { +void EditorFileDialog::_push_history() { + + local_history.resize(local_history_pos+1); + String new_path = dir_access->get_current_dir(); + if (local_history.size()==0 || new_path!=local_history[local_history_pos]) { + local_history.push_back(new_path); + local_history_pos++; + dir_prev->set_disabled(local_history_pos==0); + dir_next->set_disabled(true); + } + +} + +void EditorFileDialog::_item_dc_selected(int p_item) { - TreeItem *ti=tree->get_selected(); - if (!ti) + int current = p_item; + if (current<0 || current>=item_list->get_item_count()) return; - Dictionary d=ti->get_metadata(0); + Dictionary d=item_list->get_item_metadata(current); if (d["dir"]) { + print_line("change dir: "+String(d["name"])); dir_access->change_dir(d["name"]); if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR) file->set_text(""); call_deferred("_update_file_list"); call_deferred("_update_dir"); + + _push_history(); + + } else { _action_pressed(); } } + + void EditorFileDialog::update_file_list() { - tree->clear(); + + int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size"); + Ref folder_thumbnail; + Ref file_thumbnail; + + item_list->clear(); + + if (display_mode==DISPLAY_THUMBNAILS) { + + item_list->set_max_columns(0); + item_list->set_icon_mode(ItemList::ICON_MODE_TOP); + item_list->set_fixed_column_width(thumbnail_size*3/2); + item_list->set_max_text_lines(2); + item_list->set_min_icon_size(Size2(thumbnail_size,thumbnail_size)); + + if (!has_icon("ResizedFolder","EditorIcons")) { + Ref folder = get_icon("FolderBig","EditorIcons"); + Image img = folder->get_data(); + img.resize(thumbnail_size,thumbnail_size); + Ref resized_folder = Ref( memnew( ImageTexture)); + resized_folder->create_from_image(img,0); + Theme::get_default()->set_icon("ResizedFolder","EditorIcons",resized_folder); + } + + folder_thumbnail = get_icon("ResizedFolder","EditorIcons"); + + if (!has_icon("ResizedFile","EditorIcons")) { + Ref file = get_icon("FileBig","EditorIcons"); + Image img = file->get_data(); + img.resize(thumbnail_size,thumbnail_size); + Ref resized_file = Ref( memnew( ImageTexture)); + resized_file->create_from_image(img,0); + Theme::get_default()->set_icon("ResizedFile","EditorIcons",resized_file); + } + + file_thumbnail = get_icon("ResizedFile","EditorIcons"); + + preview_vb->hide(); + + } else { + + item_list->set_icon_mode(ItemList::ICON_MODE_LEFT); + item_list->set_max_columns(1); + item_list->set_max_text_lines(1); + item_list->set_fixed_column_width(0); + item_list->set_min_icon_size(Size2()); + if (preview->get_texture().is_valid()) + preview_vb->show(); + + } + + dir_access->list_dir_begin(); - TreeItem *root = tree->create_item(); + Ref folder = get_icon("folder","FileDialog"); List files; List dirs; @@ -320,13 +462,20 @@ void EditorFileDialog::update_file_list() { while(!dirs.empty()) { if (dirs.front()->get()!=".") { - TreeItem *ti=tree->create_item(root); - ti->set_text(0,dirs.front()->get()+"/"); - ti->set_icon(0,folder); + item_list->add_item(dirs.front()->get()+"/"); + if (display_mode==DISPLAY_THUMBNAILS) { + + item_list->set_item_icon(item_list->get_item_count()-1,folder_thumbnail); + } else { + + item_list->set_item_icon(item_list->get_item_count()-1,folder); + } + Dictionary d; d["name"]=dirs.front()->get(); + d["path"]=String(); d["dir"]=true; - ti->set_metadata(0,d); + item_list->set_item_metadata( item_list->get_item_count() -1, d); } dirs.pop_front(); @@ -382,33 +531,71 @@ void EditorFileDialog::update_file_list() { } if (match) { - TreeItem *ti=tree->create_item(root); - ti->set_text(0,files.front()->get()); + //TreeItem *ti=tree->create_item(root); + //ti->set_text(0,files.front()->get()); + item_list->add_item(files.front()->get()); if (get_icon_func) { Ref icon = get_icon_func(base_dir.plus_file(files.front()->get())); - ti->set_icon(0,icon); + //ti->set_icon(0,icon); + if (display_mode==DISPLAY_THUMBNAILS) { + + item_list->set_item_icon(item_list->get_item_count()-1,file_thumbnail); + item_list->set_item_tag_icon(item_list->get_item_count()-1,icon); + } else { + item_list->set_item_icon(item_list->get_item_count()-1,icon); + } } if (mode==MODE_OPEN_DIR) { - ti->set_custom_color(0,get_color("files_disabled")); - ti->set_selectable(0,false); + //disabled mode? + //ti->set_custom_color(0,get_color("files_disabled")); + //ti->set_selectable(0,false); } Dictionary d; d["name"]=files.front()->get(); d["dir"]=false; - ti->set_metadata(0,d); + String fullpath = base_dir.plus_file(files.front()->get()); + + if (display_mode==DISPLAY_THUMBNAILS) { + EditorResourcePreview::get_singleton()->queue_resource_preview(fullpath,this,"_thumbnail_result",fullpath); + } + d["path"]=base_dir.plus_file(files.front()->get()); + //ti->set_metadata(0,d); + item_list->set_item_metadata(item_list->get_item_count()-1,d); if (file->get_text()==files.front()->get()) - ti->select(0); + item_list->set_current(item_list->get_item_count()-1); } files.pop_front(); } - if (tree->get_root() && tree->get_root()->get_children()) - tree->get_root()->get_children()->select(0); + if (favorites->get_current()>=0) { + favorites->unselect(favorites->get_current()); + } + + favorite->set_pressed(false); + fav_up->set_disabled(true); + fav_down->set_disabled(true); + for(int i=0;iget_item_count();i++) { + if (favorites->get_item_metadata(i)==base_dir) { + favorites->select(i); + favorite->set_pressed(true); + if (i>0) { + fav_up->set_disabled(false); + } + if (iget_item_count()-1) { + fav_down->set_disabled(false); + } + break; + } + + } + // ?? + //if (tree->get_root() && tree->get_root()->get_children()) + // tree->get_root()->get_children()->select(0); files.clear(); @@ -485,6 +672,8 @@ void EditorFileDialog::set_current_dir(const String& p_dir) { dir_access->change_dir(p_dir); update_dir(); invalidate(); + _push_history(); + } void EditorFileDialog::set_current_file(const String& p_file) { @@ -533,10 +722,9 @@ void EditorFileDialog::set_mode(Mode p_mode) { } if (mode==MODE_OPEN_FILES) { - tree->set_select_mode(Tree::SELECT_MULTI); + item_list->set_select_mode(ItemList::SELECT_MULTI); } else { - tree->set_select_mode(Tree::SELECT_SINGLE); - + item_list->set_select_mode(ItemList::SELECT_SINGLE); } } @@ -597,6 +785,8 @@ void EditorFileDialog::_make_dir_confirm() { invalidate(); update_filters(); update_dir(); + _push_history(); + } else { mkdirerr->popup_centered_minsize(Size2(250,50)); } @@ -617,6 +807,8 @@ void EditorFileDialog::_select_drive(int p_idx) { file->set_text(""); invalidate(); update_dir(); + _push_history(); + } @@ -640,13 +832,214 @@ void EditorFileDialog::_update_drives() { } } + +void EditorFileDialog::_favorite_selected(int p_idx) { + + Vector favorited = EditorSettings::get_singleton()->get_favorite_dirs(); + ERR_FAIL_INDEX(p_idx,favorited.size()); + + dir_access->change_dir(favorited[p_idx]); + file->set_text(""); + invalidate(); + update_dir(); + _push_history(); +} + +void EditorFileDialog::_favorite_move_up(){ + + int current = favorites->get_current(); + + if (current>0 && currentget_item_count()) { + Vector favorited = EditorSettings::get_singleton()->get_favorite_dirs(); + + int a_idx=favorited.find(favorites->get_item_metadata(current-1)); + int b_idx=favorited.find(favorites->get_item_metadata(current)); + + if (a_idx==-1 || b_idx==-1) + return; + SWAP(favorited[a_idx],favorited[b_idx]); + + EditorSettings::get_singleton()->set_favorite_dirs(favorited); + + _update_favorites(); + update_file_list(); + + } +} +void EditorFileDialog::_favorite_move_down(){ + + int current = favorites->get_current(); + + if (current>=0 && currentget_item_count()-1) { + Vector favorited = EditorSettings::get_singleton()->get_favorite_dirs(); + + int a_idx=favorited.find(favorites->get_item_metadata(current+1)); + int b_idx=favorited.find(favorites->get_item_metadata(current)); + + if (a_idx==-1 || b_idx==-1) + return; + SWAP(favorited[a_idx],favorited[b_idx]); + + EditorSettings::get_singleton()->set_favorite_dirs(favorited); + + _update_favorites(); + update_file_list(); + + } +} + + +void EditorFileDialog::_update_favorites() { + + bool res = access==ACCESS_RESOURCES; + + String current = get_current_dir(); + Ref star = get_icon("Favorites","EditorIcons"); + favorites->clear(); + + favorite->set_pressed(false); + + + Vector favorited = EditorSettings::get_singleton()->get_favorite_dirs(); + for(int i=0;iadd_item(name,star); + favorites->set_item_metadata( favorites->get_item_count()-1,favorited[i]); + + if (setthis) { + favorite->set_pressed(true); + favorites->set_current(favorites->get_item_count()-1); + } + } + + +} + +void EditorFileDialog::_favorite_toggled(bool p_toggle) { + bool res = access==ACCESS_RESOURCES; + + String cd = get_current_dir(); + + Vector favorited = EditorSettings::get_singleton()->get_favorite_dirs(); + + bool found = false; + for(int i=0;iset_pressed(false); + } else { + favorited.push_back(cd); + favorite->set_pressed(true); + } + + EditorSettings::get_singleton()->set_favorite_dirs(favorited); + + _update_favorites(); + +} + +void EditorFileDialog::_recent_selected(int p_idx) { + + Vector recentd = EditorSettings::get_singleton()->get_recent_dirs(); + ERR_FAIL_INDEX(p_idx,recentd.size()); + + dir_access->change_dir(recent->get_item_metadata(p_idx)); + update_file_list(); + update_dir(); + _push_history(); +} + +void EditorFileDialog::_go_up() { + + dir_access->change_dir(".."); + update_file_list(); + update_dir(); + _push_history(); + +} + +void EditorFileDialog::_go_back(){ + + if (local_history_pos<=0) { + return; + } + + local_history_pos--; + dir_access->change_dir(local_history[local_history_pos]); + update_file_list(); + update_dir(); + + dir_prev->set_disabled(local_history_pos==0); + dir_next->set_disabled(local_history_pos==local_history.size()-1); +} +void EditorFileDialog::_go_forward(){ + + if (local_history_pos==local_history.size()-1) { + return; + } + + local_history_pos++; + dir_access->change_dir(local_history[local_history_pos]); + update_file_list(); + update_dir(); + + dir_prev->set_disabled(local_history_pos==0); + dir_next->set_disabled(local_history_pos==local_history.size()-1); + +} + bool EditorFileDialog::default_show_hidden_files=true; +void EditorFileDialog::set_display_mode(DisplayMode p_mode) { + + if (display_mode==p_mode) + return; + if (p_mode==DISPLAY_THUMBNAILS) { + mode_list->set_pressed(false); + mode_thumbnails->set_pressed(true); + } else { + mode_thumbnails->set_pressed(false); + mode_list->set_pressed(true); + } + display_mode=p_mode; + invalidate();; +} + +EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const{ + + return display_mode; +} + + void EditorFileDialog::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_tree_selected"),&EditorFileDialog::_tree_selected); - ObjectTypeDB::bind_method(_MD("_tree_db_selected"),&EditorFileDialog::_tree_dc_selected); + ObjectTypeDB::bind_method(_MD("_item_selected"),&EditorFileDialog::_item_selected); + ObjectTypeDB::bind_method(_MD("_item_db_selected"),&EditorFileDialog::_item_dc_selected); ObjectTypeDB::bind_method(_MD("_dir_entered"),&EditorFileDialog::_dir_entered); ObjectTypeDB::bind_method(_MD("_file_entered"),&EditorFileDialog::_file_entered); ObjectTypeDB::bind_method(_MD("_action_pressed"),&EditorFileDialog::_action_pressed); @@ -675,6 +1068,19 @@ void EditorFileDialog::_bind_methods() { ObjectTypeDB::bind_method(_MD("_update_file_list"),&EditorFileDialog::update_file_list); ObjectTypeDB::bind_method(_MD("_update_dir"),&EditorFileDialog::update_dir); ObjectTypeDB::bind_method(_MD("_thumbnail_done"),&EditorFileDialog::_thumbnail_done); + ObjectTypeDB::bind_method(_MD("set_display_mode","mode"),&EditorFileDialog::set_display_mode); + ObjectTypeDB::bind_method(_MD("get_display_mode"),&EditorFileDialog::get_display_mode); + ObjectTypeDB::bind_method(_MD("_thumbnail_result"),&EditorFileDialog::_thumbnail_result); + + ObjectTypeDB::bind_method(_MD("_recent_selected"),&EditorFileDialog::_recent_selected); + ObjectTypeDB::bind_method(_MD("_go_back"),&EditorFileDialog::_go_back); + ObjectTypeDB::bind_method(_MD("_go_forward"),&EditorFileDialog::_go_forward); + ObjectTypeDB::bind_method(_MD("_go_up"),&EditorFileDialog::_go_up); + + ObjectTypeDB::bind_method(_MD("_favorite_toggled"),&EditorFileDialog::_favorite_toggled); + ObjectTypeDB::bind_method(_MD("_favorite_selected"),&EditorFileDialog::_favorite_selected); + ObjectTypeDB::bind_method(_MD("_favorite_move_up"),&EditorFileDialog::_favorite_move_up); + ObjectTypeDB::bind_method(_MD("_favorite_move_down"),&EditorFileDialog::_favorite_move_down); ObjectTypeDB::bind_method(_MD("invalidate"),&EditorFileDialog::invalidate); @@ -707,9 +1113,36 @@ void EditorFileDialog::set_default_show_hidden_files(bool p_show) { default_show_hidden_files=p_show; } +void EditorFileDialog::_save_to_recent() { + + String dir = get_current_dir(); + Vector recent = EditorSettings::get_singleton()->get_recent_dirs(); + + const int max=20; + int count=0; + bool res=dir.begins_with("res://"); + + for(int i=0;imax)) { + recent.remove(i); + i--; + } else { + count++; + } + } + + recent.insert(0,dir); + + EditorSettings::get_singleton()->set_recent_dirs(recent); + + +} + EditorFileDialog::EditorFileDialog() { show_hidden_files=true; + display_mode=DISPLAY_THUMBNAILS; VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); @@ -718,11 +1151,39 @@ EditorFileDialog::EditorFileDialog() { mode=MODE_SAVE_FILE; set_title("Save a File"); - dir = memnew(LineEdit); HBoxContainer *pathhb = memnew( HBoxContainer ); + + dir_prev = memnew( ToolButton ); + dir_next = memnew( ToolButton ); + dir_up = memnew( ToolButton ); + + pathhb->add_child(dir_prev); + pathhb->add_child(dir_next); + pathhb->add_child(dir_up); + + dir_prev->connect("pressed",this,"_go_back"); + dir_next->connect("pressed",this,"_go_forward"); + dir_up->connect("pressed",this,"_go_up"); + + dir = memnew(LineEdit); pathhb->add_child(dir); dir->set_h_size_flags(SIZE_EXPAND_FILL); + favorite = memnew( ToolButton ); + favorite->set_toggle_mode(true); + favorite->connect("toggled",this,"_favorite_toggled"); + pathhb->add_child(favorite); + + mode_thumbnails = memnew( ToolButton ); + mode_thumbnails->connect("pressed",this,"set_display_mode",varray(DISPLAY_THUMBNAILS)); + mode_thumbnails->set_toggle_mode(true); + mode_thumbnails->set_pressed(true); + pathhb->add_child(mode_thumbnails); + mode_list = memnew( ToolButton ); + mode_list->connect("pressed",this,"set_display_mode",varray(DISPLAY_LIST)); + mode_list->set_toggle_mode(true); + pathhb->add_child(mode_list); + drives = memnew( OptionButton ); pathhb->add_child(drives); drives->connect("item_selected",this,"_select_drive"); @@ -732,18 +1193,49 @@ EditorFileDialog::EditorFileDialog() { makedir->connect("pressed",this,"_make_dir"); pathhb->add_child(makedir); - vbc->add_margin_child("Path:",pathhb); - list_hb = memnew( HBoxContainer ); - vbc->add_margin_child("Directories & Files:",list_hb,true); - tree = memnew(Tree); - tree->set_hide_root(true); - tree->set_h_size_flags(SIZE_EXPAND_FILL); - list_hb->add_child(tree); + vbc->add_margin_child("Path:",pathhb); + vbc->add_child(list_hb); + list_hb->set_v_size_flags(SIZE_EXPAND_FILL); + + VBoxContainer *fav_vb = memnew( VBoxContainer ); + list_hb->add_child(fav_vb); + HBoxContainer *fav_hb = memnew( HBoxContainer ); + fav_vb->add_child(fav_hb); + fav_hb->add_child(memnew(Label("Favorites:"))); + fav_hb->add_spacer(); + fav_up = memnew( ToolButton ); + fav_hb->add_child(fav_up); + fav_up->connect("pressed",this,"_favorite_move_up"); + fav_down = memnew( ToolButton ); + fav_hb->add_child(fav_down); + fav_down->connect("pressed",this,"_favorite_move_down"); + fav_rm = memnew( ToolButton ); + fav_hb->add_child(fav_rm); + fav_rm->hide(); // redundant + + MarginContainer *fav_mv = memnew( MarginContainer ); + fav_vb->add_child(fav_mv); + fav_mv->set_v_size_flags(SIZE_EXPAND_FILL); + favorites = memnew( ItemList ); + fav_mv->add_child(favorites); + favorites->connect("item_selected",this,"_favorite_selected"); + + recent = memnew( ItemList ); + fav_vb->add_margin_child("Recent:",recent,true); + recent->connect("item_selected",this,"_recent_selected"); + + VBoxContainer *item_vb = memnew( VBoxContainer ); + list_hb->add_child(item_vb); + item_vb->set_h_size_flags(SIZE_EXPAND_FILL); + + item_list = memnew( ItemList ); + item_list->set_v_size_flags(SIZE_EXPAND_FILL); + item_vb->add_margin_child("Directories & Files:",item_list,true); HBoxContainer* filter_hb = memnew( HBoxContainer ); - vbc->add_child(filter_hb); + item_vb->add_child(filter_hb); VBoxContainer *filter_vb = memnew( VBoxContainer ); filter_hb->add_child(filter_vb); @@ -775,8 +1267,8 @@ EditorFileDialog::EditorFileDialog() { connect("confirmed", this,"_action_pressed"); //cancel->connect("pressed", this,"_cancel_pressed"); - tree->connect("cell_selected", this,"_tree_selected",varray(),CONNECT_DEFERRED); - tree->connect("item_activated", this,"_tree_db_selected",varray()); + item_list->connect("item_selected", this,"_item_selected",varray(),CONNECT_DEFERRED); + item_list->connect("item_activated", this,"_item_db_selected",varray()); dir->connect("text_entered", this,"_dir_entered"); file->connect("text_entered", this,"_file_entered"); filter->connect("item_selected", this,"_filter_selected"); diff --git a/tools/editor/editor_file_dialog.h b/tools/editor/editor_file_dialog.h index 72b88487887..6cfd9705169 100644 --- a/tools/editor/editor_file_dialog.h +++ b/tools/editor/editor_file_dialog.h @@ -32,14 +32,14 @@ #define EDITORFILEDIALOG_H #include "scene/gui/dialogs.h" -#include "scene/gui/tree.h" +#include "scene/gui/item_list.h" #include "scene/gui/line_edit.h" #include "scene/gui/option_button.h" #include "scene/gui/dialogs.h" #include "os/dir_access.h" #include "scene/gui/box_container.h" #include "scene/gui/texture_frame.h" - +#include "scene/gui/tool_button.h" /** @author Juan Linietsky */ @@ -49,6 +49,12 @@ class EditorFileDialog : public ConfirmationDialog { public: + enum DisplayMode { + DISPLAY_THUMBNAILS, + DISPLAY_LIST + }; + + enum Access { ACCESS_RESOURCES, ACCESS_USERDATA, @@ -82,8 +88,13 @@ private: VBoxContainer *vbox; Mode mode; LineEdit *dir; + + ToolButton *dir_prev; + ToolButton *dir_next; + ToolButton *dir_up; + OptionButton *drives; - Tree *tree; + ItemList *item_list; TextureFrame *preview; VBoxContainer *preview_vb; HBoxContainer *list_hb; @@ -93,6 +104,22 @@ private: OptionButton *filter; DirAccess *dir_access; ConfirmationDialog *confirm_save; + ToolButton *mode_thumbnails; + ToolButton *mode_list; + + + ToolButton *favorite; + + ToolButton *fav_up; + ToolButton *fav_down; + ToolButton *fav_rm; + + ItemList *favorites; + ItemList *recent; + + Vector local_history; + int local_history_pos; + void _push_history(); Vector filters; @@ -101,6 +128,7 @@ private: float preview_wheel_timeout; static bool default_show_hidden_files; bool show_hidden_files; + DisplayMode display_mode; bool invalidated; @@ -108,10 +136,20 @@ private: void update_file_list(); void update_filters(); - void _tree_selected(); + void _update_favorites(); + void _favorite_toggled(bool p_toggle); + void _favorite_selected(int p_idx); + void _favorite_move_up(); + void _favorite_move_down(); + + + + void _recent_selected(int p_idx); + + void _item_selected(int p_item); + void _item_dc_selected(int p_item); void _select_drive(int p_idx); - void _tree_dc_selected(); void _dir_entered(String p_dir); void _file_entered(const String& p_file); void _action_pressed(); @@ -123,11 +161,16 @@ private: void _update_drives(); + void _go_up(); + void _go_back(); + void _go_forward(); + virtual void _post_popup(); - + void _save_to_recent(); //callback funtion is callback(String p_path,Ref preview,Variant udata) preview null if could not load + void _thumbnail_result(const String& p_path,const Ref& p_preview, const Variant& p_udata); void _thumbnail_done(const String& p_path,const Ref& p_preview, const Variant& p_udata); void _request_single_thumbnail(const String& p_path); @@ -151,6 +194,9 @@ public: void set_current_file(const String& p_file); void set_current_path(const String& p_path); + void set_display_mode(DisplayMode p_mode); + DisplayMode get_display_mode() const; + void set_mode(Mode p_mode); Mode get_mode() const; @@ -194,5 +240,6 @@ public: VARIANT_ENUM_CAST( EditorFileDialog::Mode ); VARIANT_ENUM_CAST( EditorFileDialog::Access ); +VARIANT_ENUM_CAST( EditorFileDialog::DisplayMode ); #endif // EDITORFILEDIALOG_H diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index ae083db0ff3..d741087a9f6 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -33,7 +33,7 @@ #include "os/file_access.h" #include "editor_node.h" #include "io/resource_saver.h" - +#include "editor_settings.h" EditorFileSystem *EditorFileSystem::singleton=NULL; @@ -357,7 +357,9 @@ void EditorFileSystem::_scan_scenes() { String project=Globals::get_singleton()->get_resource_path(); - FileAccess *f =FileAccess::open(project+"/.fscache",FileAccess::READ); + + String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("file_cache"); + FileAccess *f =FileAccess::open(fscache,FileAccess::READ); if (f) { //read the disk cache @@ -470,7 +472,9 @@ void EditorFileSystem::_scan_scenes() { //save back the findings - f=FileAccess::open(project+"/.fscache",FileAccess::WRITE); +// String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("file_cache"); + + f=FileAccess::open(fscache,FileAccess::WRITE); _save_type_cache_fs(scandir,f); f->close(); memdelete(f); diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index 9b7d8d227e0..86f6661e8a8 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -33,7 +33,7 @@ void EditorResourcePreview::_thread_func(void *ud) { void EditorResourcePreview::_preview_ready(const String& p_str,const Ref& p_texture,ObjectID id,const StringName& p_func,const Variant& p_ud) { - print_line("preview is ready"); + //print_line("preview is ready"); preview_mutex->lock(); Item item; @@ -52,7 +52,7 @@ void EditorResourcePreview::_preview_ready(const String& p_str,const Ref EditorResourcePreview::_generate_preview(const QueueItem& p_item,const String& cache_base) { String type = ResourceLoader::get_resource_type(p_item.path); - print_line("resource type is: "+type); + //print_line("resource type is: "+type); if (type=="") return Ref(); //could not guess type @@ -68,7 +68,7 @@ Ref EditorResourcePreview::_generate_preview(const QueueItem& p_item,co } if (generated.is_valid()) { - print_line("was generated"); + //print_line("was generated"); int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size"); //wow it generated a preview... save cache ResourceSaver::save(cache_base+".png",generated); @@ -78,7 +78,7 @@ Ref EditorResourcePreview::_generate_preview(const QueueItem& p_item,co f->store_line(FileAccess::get_md5(p_item.path)); memdelete(f); } else { - print_line("was not generated"); + //print_line("was not generated"); } @@ -87,18 +87,18 @@ Ref EditorResourcePreview::_generate_preview(const QueueItem& p_item,co void EditorResourcePreview::_thread() { - print_line("begin thread"); + //print_line("begin thread"); while(!exit) { - print_line("wait for semaphore"); + //print_line("wait for semaphore"); preview_sem->wait(); preview_mutex->lock(); - print_line("blue team go"); + //print_line("blue team go"); if (queue.size()) { - print_line("pop from queue"); + //print_line("pop from queue"); QueueItem item = queue.front()->get(); queue.pop_front(); @@ -124,11 +124,11 @@ void EditorResourcePreview::_thread() { //does not have it, try to load a cached thumbnail String file = cache_base+".txt"; - print_line("cachetxt at "+file); + //print_line("cachetxt at "+file); FileAccess *f=FileAccess::open(file,FileAccess::READ); if (!f) { - print_line("generate because not cached"); + //print_line("generate because not cached"); //generate texture=_generate_preview(item,cache_base); @@ -179,7 +179,7 @@ void EditorResourcePreview::_thread() { } - print_line("notify of preview ready"); + //print_line("notify of preview ready"); call_deferred("_preview_ready",item.path,texture,item.id,item.function,item.userdata); } @@ -206,7 +206,7 @@ void EditorResourcePreview::queue_resource_preview(const String& p_path, Object* } - print_line("send to thread"); + //print_line("send to thread"); QueueItem item; item.function=p_receiver_func; item.id=p_receiver->get_instance_ID(); diff --git a/tools/editor/editor_resource_preview.h b/tools/editor/editor_resource_preview.h index f8b96eca224..aadae755970 100644 --- a/tools/editor/editor_resource_preview.h +++ b/tools/editor/editor_resource_preview.h @@ -8,9 +8,9 @@ /* make previews for: *packdscene --wav +*wav *image --mesh +*mesh -font *script *material diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 2fac05753a4..361a86b88ef 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -224,6 +224,28 @@ void EditorSettings::create() { dir->change_dir(".."); } + if (dir->change_dir("config")!=OK) { + dir->make_dir("config"); + } else { + + dir->change_dir(".."); + } + + dir->change_dir("config"); + + String pcp=Globals::get_singleton()->get_resource_path(); + if (pcp.ends_with("/")) + pcp=config_path.substr(0,pcp.size()-1); + pcp=pcp.get_file()+"-"+pcp.md5_text(); + + if (dir->change_dir(pcp)) { + dir->make_dir(pcp); + } else { + dir->change_dir(".."); + } + + dir->change_dir(".."); + // path at least is validated, so validate config file @@ -244,6 +266,7 @@ void EditorSettings::create() { } singleton->config_file_path=config_file_path; + singleton->project_config_path=pcp; singleton->settings_path=config_path+"/"+config_dir; if (OS::get_singleton()->is_stdout_verbose()) { @@ -251,7 +274,7 @@ void EditorSettings::create() { print_line("EditorSettings: Load OK!"); } - + singleton->load_favorites(); singleton->scan_plugins(); return; @@ -648,6 +671,71 @@ void EditorSettings::set_plugin_enabled(const String& p_plugin, bool p_enabled) } +void EditorSettings::set_favorite_dirs(const Vector& p_favorites) { + + favorite_dirs=p_favorites; + FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("favorite_dirs"),FileAccess::WRITE); + if (f) { + for(int i=0;istore_line(favorite_dirs[i]); + memdelete(f); + } + +} + +Vector EditorSettings::get_favorite_dirs() const { + + return favorite_dirs; +} + + +void EditorSettings::set_recent_dirs(const Vector& p_recent) { + + recent_dirs=p_recent; + FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("recent_dirs"),FileAccess::WRITE); + if (f) { + for(int i=0;istore_line(recent_dirs[i]); + memdelete(f); + } +} + +Vector EditorSettings::get_recent_dirs() const { + + return recent_dirs; +} + +String EditorSettings::get_project_settings_path() const { + + + return get_settings_path().plus_file("config").plus_file(project_config_path); +} + + +void EditorSettings::load_favorites() { + + FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("favorite_dirs"),FileAccess::READ); + if (f) { + String line = f->get_line().strip_edges(); + while(line!="") { + favorite_dirs.push_back(line); + line = f->get_line().strip_edges(); + } + memdelete(f); + } + + f = FileAccess::open(get_project_settings_path().plus_file("recent_dirs"),FileAccess::READ); + if (f) { + String line = f->get_line().strip_edges(); + while(line!="") { + recent_dirs.push_back(line); + line = f->get_line().strip_edges(); + } + memdelete(f); + } + +} + void EditorSettings::_bind_methods() { diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h index 1594719a928..6b7e6eb9892 100644 --- a/tools/editor/editor_settings.h +++ b/tools/editor/editor_settings.h @@ -88,6 +88,11 @@ private: void _load_defaults(); + String project_config_path; + + Vector favorite_dirs; + Vector recent_dirs; + protected: static void _bind_methods(); @@ -102,6 +107,7 @@ public: static EditorSettings *get_singleton(); void erase(String p_var); String get_settings_path() const; + String get_project_settings_path() const; const Map& get_plugins() const { return plugins; } @@ -125,6 +131,14 @@ public: void add_property_hint(const PropertyInfo& p_hint); + void set_favorite_dirs(const Vector& p_favorite_dirs); + Vector get_favorite_dirs() const; + + void set_recent_dirs(const Vector& p_recent_dirs); + Vector get_recent_dirs() const; + + void load_favorites(); + EditorSettings(); ~EditorSettings(); diff --git a/tools/editor/editor_sub_scene.cpp b/tools/editor/editor_sub_scene.cpp index 49385daeaaa..2a6eba2554a 100644 --- a/tools/editor/editor_sub_scene.cpp +++ b/tools/editor/editor_sub_scene.cpp @@ -215,7 +215,7 @@ EditorSubScene::EditorSubScene() { tree->set_v_size_flags(SIZE_EXPAND_FILL); vb->add_margin_child("Import From Node:",tree)->set_v_size_flags(SIZE_EXPAND_FILL); - file_dialog = memnew( FileDialog ); + file_dialog = memnew( EditorFileDialog ); List extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions); @@ -224,7 +224,7 @@ EditorSubScene::EditorSubScene() { file_dialog->add_filter("*."+E->get()); } - file_dialog->set_mode(FileDialog::MODE_OPEN_FILE); + file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); add_child(file_dialog); file_dialog->connect("file_selected",this,"_path_selected"); diff --git a/tools/editor/editor_sub_scene.h b/tools/editor/editor_sub_scene.h index 9d78dab2a24..dfd6c531e2c 100644 --- a/tools/editor/editor_sub_scene.h +++ b/tools/editor/editor_sub_scene.h @@ -31,7 +31,7 @@ #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" -#include "scene/gui/file_dialog.h" +#include "tools/editor/editor_file_dialog.h" class EditorSubScene : public ConfirmationDialog { @@ -42,7 +42,7 @@ class EditorSubScene : public ConfirmationDialog { Tree *tree; Node *scene; - FileDialog *file_dialog; + EditorFileDialog *file_dialog; void _fill_tree(Node* p_node,TreeItem *p_parent); void _reown(Node* p_node,List *p_to_reown); diff --git a/tools/editor/icons/icon_arrow_left.png b/tools/editor/icons/icon_arrow_left.png new file mode 100644 index 0000000000000000000000000000000000000000..b72ac2a10d5ae445538fed83618e5770ae14b110 GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0vp^JU}eK!3HFi66di4Db50q$YKTtZeb8+WSBKa0w~B{ z;_2(kexHq%N6n)2$zd^|kZfj1M2T~LZfnvA2>=5@O+VD3ktY;HKBo3V0j{YhFAY2>CA#Rj4G8nwnrtN i=DvKi`CoO6>`ulMZ;j3V{XeQe&hd2hb6Mw<&;$VNR!}tn literal 0 HcmV?d00001 diff --git a/tools/editor/icons/icon_arrow_right.png b/tools/editor/icons/icon_arrow_right.png new file mode 100644 index 0000000000000000000000000000000000000000..d0a48b01acce81144a6c44b9480d228e3f4d3dab GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^JU}eK!3HFi66di4Db50q$YKTtZeb8+WSBKa0w~B{ z;_2(kexHq%M@{|5n{$tWLb9155hc#~xw)x%B|t6%gL6@8Vo7R>LV0FMhJw4NZ$OG( zD#*ZEPZ!4!jq_J08gexU2)NAum^}FyGsop85>@N&915=Fna%iiazk&gnZ3fN+44>b z!DkPhd3R3lk9bbIzt8QBdO6b_W(s*nEl!+vg@I)O^Q|c-ziD5(^-X0ZXJ8Hcsv{G= zTV21Au;)n{*MWiu={AjW5e@B2qRU>q*>kADwC#G*?0=dxB)z4*}Q$iB} D#YJ7z literal 0 HcmV?d00001 diff --git a/tools/editor/icons/icon_arrow_right_disabled.png b/tools/editor/icons/icon_arrow_right_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..840cd0da0a3aaa52cd2c04c4cc6c5abdad2a5344 GIT binary patch literal 252 zcmeAS@N?(olHy`uVBq!ia0vp^JU}eK!3HFi66di4Db50q$YKTtZeb8+WSBKa0w~B{ z;_2(kexHq%M@vmPZet}-NH#MhqQp5rH#aq}1juDza4t$sEJ;mKD9T z1sPc6>EaloasKK=Lq3N90T=l?lXVM9cxLXH8f|gqnBkTx6)E1c(>nrc1UpxjO|Cq7 zM(>Yz+Ov5MuM7Ln=rB&w-n`@}^WG&j>{<)5+Ij>!MP|ku_QG`p**uBL&4qCHy}kX zl^rNv>FMGaqH%uj1V^qz1_G|}OG=a@_!XY?SS~&oobq`gdqMDoO9A43DFup=9n8%2 z|LQ*^K3J~2(nISWx89t_&2zs?Jbuc%<3q-QOA8b--@o;rB)4tlPj+tigiWUy=A5Z! zy#I{JzaVvBIy z!T8HUlS5^5n97{^Tpfa*@w1e;+1s8xXNnLkLk9oU800000NkvXX Hu0mjf!akVO delta 322 zcmV-I0log51NQ=uBpd;AQb$4nuFf3k00006VoOIv00jX50IIn-N)(YH9)H>j4iYf} z;_vJG0002@NklK74P)Um9o`}%i$Y4rh2!teZ zn(HAnL%%^gl#JcFbnF+%UdY_BV8~c#DA_xdd#RyQhQvg2gvsC`;Gu13JSdW-w@ZAv zln%YJt?PvM0WE^_M~{B*IRYI(5ClOG1YyDHbUNsCI*T{4FbolfA+4>gJxQ@NZ3o?M z*CryRl=>dPmjFJT)#R8N-X}w;D=Xs_3SEU*$g=Vuk2JjnzVs7>M7;_?mWmy;w zhhXM{nQs9s<$3N5hr_AHC?(+j{$58>^pcsqvVFXZY}a*BtJM(4F_>8~a}MC|?d|O} zO;de!byckZt+gVeF9788UZu6xa9tO^@8k0F60YllnKghcilRS*AjkozIF73mkftdB zcvT1h0LO8#y1I&ujSZZfoWK|ZX11Bx3&U`*ySrO#ZEfM`=%^Y2%#2xWL;t4)EX%^m z$_m!k*HN$6(QdbqBnhS z-}i0b_dh*5JNuT1emFcl%$}V9B7#y1#u#X=VT?hoR>Q-?1BeL57;TJ6nE81oV3GnN zg6q1lZ5zfI>Y5g-CYfCvx)B0vO)01+SpM1Tko0U|&IhyW2F0z|-*gv&H4^=HVkEHLvz z$s?ky$^{XE z)7O>#J{t=&7whuaBOif6vY8S|xv6<2KrRD=b5UwyNotBhd1gt5g1e`0K#E=} zJ5apJ)5S5w;`G%?8+jWHcv$#bjtEVxn_8mdbeze6QO9Ars>aJrUMkZTELQx&rgEfQ z@7|~R@^Y&fJTxm0Nbd~{T61n8W7Xp(sg9a;XBMzVEjIVyQr#b(W^k|Ku}bC%+la=y yQA@&=Ee=TToxMcY{lz;220b?84H5bktp^#;CdtV9E=y?vInUG8&t;ucLK6UBic(?# literal 0 HcmV?d00001 diff --git a/tools/editor/icons/icon_file_thumbnail.png b/tools/editor/icons/icon_file_thumbnail.png new file mode 100644 index 0000000000000000000000000000000000000000..c32be5e8f8c3931e2678e2a43d26bd05104a867b GIT binary patch literal 296 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#J{t=&r*v8Usz9KSY-UJAiF1B#Zfaf$kjuc}T$GwvlA5AWo>`Ki;O^-gkfN8$ z4iul~>Eak-ar*2;N3KH#0DG8+7I(1ek=q9zxg)g>`bHPLImGU$1UPj~ z+Vvtw?cqn`ng0_LLmASZF-+eO79{^ev_kcc_b1;S77yk~UTCkI@w4H+PHdtr{}$F; z@1=}apIP%u^%&m^p=%yhZ2MU6amuUk8XmJPm?O<#WAuh;&LZ~YM)t?MlGbo1*pA~~FyF2XTrMj~fON*J{~ z8$;5F;+(nno^!7W^ytx}M~@yo{;yy*i#X?D%@SRHO+*wSf^>9mF|-P_!Gd-0RC>PGJ~4Uj{tD%(y!E$zYeI{#3B>+Er8#TkB@&? zwGq-e0mHgeS4u%C1t}$@l+ap3YhC#rS4UdFFbu=5*5L$oUIc45FN8pnB#7e}Ns>Sa zQAt7-Idv(ewPsNieZ39>R9y;at&wFJ;yA|b?JcgauW^5Wk2sDYrCgd0HUyY8<+Y5l zU^1C(TNcX^5v7faU|wli?gbW`1St{6F>Y>daCv!&ySqD_oSf8dY&05K5fFx9+e4lL z_(Vimn{H57o&Lka1Fo*FaDIM{)6-L{BG`peFvfJvUL=5bMD(m}H<;zsm@Ohf2!Z*0 z{xSy3_=Ku$75t!=G(mE ztjfx}M8MKIU?N~|Z_h`&Ur9i14XAR1#sf$xk)|o8(`nZ>xHX9AV;dh(G(*E>GH6oZ z@bJ(l0%|>s3js?bz(`@5rih}*r^ByR0NWa%>QcZ&fRFiKr2w`BEQ|o9)MEh@Lil$2 zCc59$4RZz-MMUSt@CzqbBw%}c+s6oa+nRvVh-+Znm&t#V0=v7rP)e=S1==XUO&2xb zQ4z~*mOVg&LC7i#;DyaX7XqG`p`r&6LSTP?-!}<-+cg2a>;{bl3L$(mK^nlDIt8#M zV38Xv=6{kTI5;@)iGZPv0=PuL!r7o9AWhTGdi-@NfQt$|nGF_)ph5_*Dt|!%KG>Rt zM!wo(51;_Nw_R+V0z|a52JGzYY+MiEL_qn!FJ=&8B49F^_%sMH3NY+40t`|kg~cw= zvq8u(j{v<20yqG*0fP`L1#s;J3<2MGJ_rF3UAeT3E|`6ees2dM3cv@KFIcBQ?gnR` z4??VafF?CS1GrF14Lu%&I4M9A0%o2MLYx%9l>h~RFB^nxq5?Qa01;gjZLskGJ`q4f z|F}G%I&iq~qX8=V0FOL?0&wg4r6z4$tUm) zuU!V+45QRUR@Y6-5 z`WRIO7huC7vdbm1<^bLF2wk(|43(;i3j{?R0-+!wlqv$I8#@iDL5@0`@yz&*=RJ)T z*0M711ByVKJiJr@kxLY({p*>F3BZa*AAz*ad>p>s>1YlU0SMB|%Dlh+-c$gIi50-2 zSc)$mkDdqH)2;`g0Tk-eg+HJy=2rt(urGOIH%V6J19zd_fW*Z0c~LB{VxP4ehy|%; z+@L4c4;?^<5Kc^dbCMtp8jZp<2;qKL13+0Xtx5bE2%;OsKb$=ph{gPWm1~hc539E> npK10uO|LXC(bK%+Is@_CX>@2HM@dakWG-a~0004fNklI|KGE+q8ugpA)>o|rfHt;+m-mL61D6od(7(~QgW!jPa@)eo0*E(#Ye1H!eT{WP_e`b%sR3=&pJ-l zho+o#B2D2r+JCY?&djE*!&fWd{hu5R@ent0(7Wc#!i)M(-r{v; bHdy=srxk=7!_|Ft00000NkvXXu0mjfDE;8x delta 363 zcmV-x0hIoS1daocEPoOJ01FZU(%pXi0000PbVXQnLvL+uWo~o;Lvm$dbY)~9cWHEJ zAV*0}P*;Ht7XSbO8%ab#R5*>zQoByXKn$F7(oi_jih?#h2*g8(6A~c!XNvm)4v7;z zN3nmfg;PP!rrAZlBp+~=R+jCZkv%qWP?l1vy&u)8xf*$}nSY(c7)@0#{l}CNsp?aV z(afyzwS{MkF&Y2`K+JqgM4tduRbND81z-oD>bh<*AxJ6Js(K|N?{XE z)7O>#J{v2qvhdQkOH_bDvY8S|xv6<2KrRD=b5UwyNotBhd1gt5g1e`0K#E=} zJ5YSSr;B5V#AVkr`@NhBW!gTT|0u(yB*4D>-=7vWR`=Z;`U@5wT%D2so@r0RJEs_F z6^HRA%9@=n7 z>imw6`-QZ1v|=8J`hGEV=MUZ!V)?UCzsKNM@ISv^oi{}fg|5$3?yEn<&$i>Z@~$0+ m7B&jo6}GEd-AI}owCeng>l*K;Jadd_child(vbr); vbr->set_h_size_flags(SIZE_EXPAND_FILL); - source = memnew( LineEditFileChooser ); - source->get_file_dialog()->set_access(FileDialog::ACCESS_FILESYSTEM); - source->get_file_dialog()->set_mode(FileDialog::MODE_OPEN_FILE); + source = memnew( EditorLineEditFileChooser ); + source->get_file_dialog()->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + source->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE); source->get_file_dialog()->add_filter("*.ttf;TrueType"); source->get_file_dialog()->add_filter("*.otf;OpenType"); source->get_line_edit()->connect("text_entered",this,"_src_changed"); @@ -626,7 +626,7 @@ public: font_size->set_max(256); font_size->set_val(16); font_size->connect("value_changed",this,"_font_size_changed"); - dest = memnew( LineEditFileChooser ); + dest = memnew( EditorLineEditFileChooser ); // List fl; Ref font= memnew(Font); diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp index 7d6f400ccc4..2e5a6f8a819 100644 --- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp @@ -1,6 +1,6 @@ #include "editor_mesh_import_plugin.h" -#include "scene/gui/file_dialog.h" +#include "tools/editor/editor_file_dialog.h" #include "tools/editor/editor_dir_dialog.h" #include "tools/editor/editor_node.h" #include "tools/editor/property_editor.h" @@ -126,7 +126,7 @@ class EditorMeshImportDialog : public ConfirmationDialog { LineEdit *import_path; LineEdit *save_path; - FileDialog *file_select; + EditorFileDialog *file_select; EditorDirDialog *save_select; ConfirmationDialog *error_dialog; PropertyEditor *option_editor; @@ -300,16 +300,16 @@ public: save_choose->connect("pressed", this,"_browse_target"); - file_select = memnew(FileDialog); - file_select->set_access(FileDialog::ACCESS_FILESYSTEM); + file_select = memnew(EditorFileDialog); + file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); add_child(file_select); - file_select->set_mode(FileDialog::MODE_OPEN_FILES); + file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); file_select->connect("files_selected", this,"_choose_files"); file_select->add_filter("*.obj ; Wavefront OBJ"); save_select = memnew( EditorDirDialog ); add_child(save_select); - // save_select->set_mode(FileDialog::MODE_OPEN_DIR); + // save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR); save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp index fa472ed0336..9491f957c39 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_sample_import_plugin.h" -#include "scene/gui/file_dialog.h" +#include "tools/editor/editor_file_dialog.h" #include "tools/editor/editor_dir_dialog.h" #include "tools/editor/editor_node.h" #include "tools/editor/property_editor.h" @@ -171,7 +171,7 @@ class EditorSampleImportDialog : public ConfirmationDialog { LineEdit *import_path; LineEdit *save_path; - FileDialog *file_select; + EditorFileDialog *file_select; EditorDirDialog *save_select; ConfirmationDialog *error_dialog; PropertyEditor *option_editor; @@ -363,16 +363,16 @@ public: save_choose->connect("pressed", this,"_browse_target"); - file_select = memnew(FileDialog); - file_select->set_access(FileDialog::ACCESS_FILESYSTEM); + file_select = memnew(EditorFileDialog); + file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); add_child(file_select); - file_select->set_mode(FileDialog::MODE_OPEN_FILES); + file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); file_select->connect("files_selected", this,"_choose_files"); file_select->add_filter("*.wav ; MS Waveform"); save_select = memnew( EditorDirDialog ); add_child(save_select); - // save_select->set_mode(FileDialog::MODE_OPEN_DIR); + // save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR); save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 2ce5f3a5a76..99dcf4ed289 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -162,8 +162,8 @@ class EditorSceneImportDialog : public ConfirmationDialog { LineEdit *save_path; LineEdit *script_path; Tree *import_options; - FileDialog *file_select; - FileDialog *script_select; + EditorFileDialog *file_select; + EditorFileDialog *script_select; EditorDirDialog *save_select; OptionButton *texture_action; @@ -1079,19 +1079,19 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce vbc->set_v_size_flags(SIZE_EXPAND_FILL); vbc->add_margin_child("Options:",import_options,true); - file_select = memnew(FileDialog); - file_select->set_access(FileDialog::ACCESS_FILESYSTEM); + file_select = memnew(EditorFileDialog); + file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); add_child(file_select); - file_select->set_mode(FileDialog::MODE_OPEN_FILE); + file_select->set_mode(EditorFileDialog::MODE_OPEN_FILE); file_select->connect("file_selected", this,"_choose_file"); save_select = memnew(EditorDirDialog); add_child(save_select); - //save_select->set_mode(FileDialog::MODE_SAVE_FILE); + //save_select->set_mode(EditorFileDialog::MODE_SAVE_FILE); save_select->connect("dir_selected", this,"_choose_save_file"); get_ok()->connect("pressed", this,"_import"); @@ -1140,7 +1140,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce script_choose->connect("pressed", this,"_browse_script"); - script_select = memnew(FileDialog); + script_select = memnew(EditorFileDialog); add_child(script_select); for(int i=0;iset_mode(FileDialog::MODE_OPEN_FILE); + script_select->set_mode(EditorFileDialog::MODE_OPEN_FILE); script_select->connect("file_selected", this,"_choose_script"); diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 3add30d81e4..7549a4d32d5 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -247,8 +247,8 @@ class EditorTextureImportDialog : public ConfirmationDialog { LineEdit *import_path; LineEdit *save_path; - FileDialog *file_select; - FileDialog *save_file_select; + EditorFileDialog *file_select; + EditorFileDialog *save_file_select; EditorDirDialog *save_select; OptionButton *texture_action; ConfirmationDialog *error_dialog; @@ -529,16 +529,16 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* save_choose->connect("pressed", this,"_browse_target"); - file_select = memnew(FileDialog); - file_select->set_access(FileDialog::ACCESS_FILESYSTEM); + file_select = memnew(EditorFileDialog); + file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); add_child(file_select); - file_select->set_mode(FileDialog::MODE_OPEN_FILES); + file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); file_select->connect("files_selected", this,"_choose_files"); - save_file_select = memnew(FileDialog); - save_file_select->set_access(FileDialog::ACCESS_RESOURCES); + save_file_select = memnew(EditorFileDialog); + save_file_select->set_access(EditorFileDialog::ACCESS_RESOURCES); add_child(save_file_select); - save_file_select->set_mode(FileDialog::MODE_SAVE_FILE); + save_file_select->set_mode(EditorFileDialog::MODE_SAVE_FILE); save_file_select->clear_filters(); save_file_select->add_filter("*.tex;Base Atlas Texture"); save_file_select->connect("file_selected", this,"_choose_save_dir"); @@ -546,7 +546,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* save_select = memnew( EditorDirDialog ); add_child(save_select); -// save_select->set_mode(FileDialog::MODE_OPEN_DIR); +// save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR); save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.cpp b/tools/editor/io_plugins/editor_translation_import_plugin.cpp index 6d59b52fb58..d152d71af44 100644 --- a/tools/editor/io_plugins/editor_translation_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_translation_import_plugin.cpp @@ -47,7 +47,7 @@ class EditorTranslationImportDialog : public ConfirmationDialog { LineEdit *import_path; LineEdit *save_path; - FileDialog *file_select; + EditorFileDialog *file_select; CheckButton *ignore_first; CheckButton *compress; CheckButton *add_to_project; @@ -347,16 +347,16 @@ public: add_to_project->set_text("Add to Project (engine.cfg)"); tcomp->add_child(add_to_project); - file_select = memnew(FileDialog); - file_select->set_access(FileDialog::ACCESS_FILESYSTEM); + file_select = memnew(EditorFileDialog); + file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); add_child(file_select); - file_select->set_mode(FileDialog::MODE_OPEN_FILE); + file_select->set_mode(EditorFileDialog::MODE_OPEN_FILE); file_select->connect("file_selected", this,"_choose_file"); file_select->add_filter("*.csv ; Translation CSV"); save_select = memnew( EditorDirDialog ); add_child(save_select); - // save_select->set_mode(FileDialog::MODE_OPEN_DIR); + // save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR); save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index 9a93eed9694..05b12543d2f 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -98,7 +98,7 @@ void AnimationPlayerEditor::_notification(int p_what) { duplicate_anim->set_icon( get_icon("Duplicate","EditorIcons") ); autoplay->set_icon( get_icon("AutoPlay","EditorIcons") ); load_anim->set_icon( get_icon("Folder","EditorIcons") ); - remove_anim->set_icon( get_icon("Del","EditorIcons") ); + remove_anim->set_icon( get_icon("Remove","EditorIcons") ); edit_anim->set_icon( get_icon("Edit","EditorIcons") ); blend_anim->set_icon( get_icon("Blend","EditorIcons") ); play->set_icon( get_icon("PlayStart","EditorIcons") ); @@ -355,7 +355,7 @@ void AnimationPlayerEditor::_animation_rename() { } void AnimationPlayerEditor::_animation_load() { ERR_FAIL_COND(!player); - file->set_mode( FileDialog::MODE_OPEN_FILE ); + file->set_mode( EditorFileDialog::MODE_OPEN_FILE ); file->clear_filters(); List extensions; @@ -1232,7 +1232,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { resource_edit_anim->hide(); - file = memnew(FileDialog); + file = memnew(EditorFileDialog); add_child(file); name_dialog = memnew( ConfirmationDialog ); diff --git a/tools/editor/plugins/animation_player_editor_plugin.h b/tools/editor/plugins/animation_player_editor_plugin.h index 5c9dc6cab84..9f0413088d7 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.h +++ b/tools/editor/plugins/animation_player_editor_plugin.h @@ -84,7 +84,7 @@ class AnimationPlayerEditor : public VBoxContainer { Ref autoplay_icon; bool last_active; - FileDialog *file; + EditorFileDialog *file; struct BlendEditor { diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp index 2df9377daf3..382bc447264 100644 --- a/tools/editor/plugins/animation_tree_editor_plugin.cpp +++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp @@ -1193,7 +1193,7 @@ void AnimationTreeEditor::_add_menu_item(int p_item) { } else if (p_item == MENU_IMPORT_ANIMATIONS) { file_op = MENU_IMPORT_ANIMATIONS; - file_dialog->set_mode(FileDialog::MODE_OPEN_FILE); + file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); file_dialog->popup_centered_ratio(); } else { @@ -1458,7 +1458,7 @@ AnimationTreeEditor::AnimationTreeEditor() { edit_check->hide();; edit_check->connect("pressed", this,"_edit_dialog_changed"); - file_dialog = memnew( FileDialog ); + file_dialog = memnew( EditorFileDialog ); file_dialog->set_enable_multiple_selection(true); file_dialog->set_current_dir(Globals::get_singleton()->get_resource_path()); add_child(file_dialog); diff --git a/tools/editor/plugins/animation_tree_editor_plugin.h b/tools/editor/plugins/animation_tree_editor_plugin.h index beb67c71966..bd29530c7ae 100644 --- a/tools/editor/plugins/animation_tree_editor_plugin.h +++ b/tools/editor/plugins/animation_tree_editor_plugin.h @@ -79,7 +79,7 @@ class AnimationTreeEditor : public Control { Button *edit_button; Button *filter_button; CheckButton *edit_check; - FileDialog* file_dialog; + EditorFileDialog* file_dialog; int file_op; void _popup_edit_dialog(); diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp index 7d243b8a65d..c1184850833 100644 --- a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp +++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp @@ -269,8 +269,8 @@ void MeshLibraryEditor::_bind_methods() { MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { - file = memnew( FileDialog ); - file->set_mode(FileDialog::MODE_OPEN_FILE); + file = memnew( EditorFileDialog ); + file->set_mode(EditorFileDialog::MODE_OPEN_FILE); //not for now? List extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions); diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.h b/tools/editor/plugins/cube_grid_theme_editor_plugin.h index 70ccef2add8..583ddf6e148 100644 --- a/tools/editor/plugins/cube_grid_theme_editor_plugin.h +++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.h @@ -42,7 +42,7 @@ class MeshLibraryEditor : public Control { EditorNode *editor; MenuButton *menu; ConfirmationDialog *cd; - FileDialog *file; + EditorFileDialog *file; int to_erase; enum { diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp index 629b4fdc641..fdf534a3a84 100644 --- a/tools/editor/plugins/particles_2d_editor_plugin.cpp +++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp @@ -172,14 +172,14 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { menu->get_popup()->add_item("Clear Emission Mask",MENU_CLEAR_EMISSION_MASK); menu->set_text("Particles"); - file = memnew(FileDialog); + file = memnew(EditorFileDialog); add_child(file); List ext; ImageLoader::get_recognized_extensions(&ext); for(List::Element *E=ext.front();E;E=E->next()) { file->add_filter("*."+E->get()+"; "+E->get().to_upper()); } - file->set_mode(FileDialog::MODE_OPEN_FILE); + file->set_mode(EditorFileDialog::MODE_OPEN_FILE); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(menu); epoints = memnew( SpinBox ); epoints->set_min(1); diff --git a/tools/editor/plugins/particles_2d_editor_plugin.h b/tools/editor/plugins/particles_2d_editor_plugin.h index 0c355a8c8c2..dba0bb4dae2 100644 --- a/tools/editor/plugins/particles_2d_editor_plugin.h +++ b/tools/editor/plugins/particles_2d_editor_plugin.h @@ -48,7 +48,7 @@ class Particles2DEditorPlugin : public EditorPlugin { }; - FileDialog *file; + EditorFileDialog *file; EditorNode *editor; MenuButton *menu; diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp index 34312205268..f6f01d82ca9 100644 --- a/tools/editor/plugins/particles_editor_plugin.cpp +++ b/tools/editor/plugins/particles_editor_plugin.cpp @@ -394,7 +394,7 @@ ParticlesEditor::ParticlesEditor() { add_child(err_dialog); - emission_file_dialog = memnew( FileDialog ); + emission_file_dialog = memnew( EditorFileDialog ); add_child(emission_file_dialog); emission_file_dialog->connect("file_selected",this,"_resource_seleted"); emission_tree_dialog = memnew( SceneTreeDialog ); @@ -410,7 +410,7 @@ ParticlesEditor::ParticlesEditor() { emission_file_dialog->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper()); } - emission_file_dialog->set_mode(FileDialog::MODE_OPEN_FILE); + emission_file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); //options->set_anchor(MARGIN_LEFT,Control::ANCHOR_END); //options->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); diff --git a/tools/editor/plugins/particles_editor_plugin.h b/tools/editor/plugins/particles_editor_plugin.h index cc13b4f2a90..92756af1f64 100644 --- a/tools/editor/plugins/particles_editor_plugin.h +++ b/tools/editor/plugins/particles_editor_plugin.h @@ -48,7 +48,7 @@ class ParticlesEditor : public Control { Particles *node; - FileDialog *emission_file_dialog; + EditorFileDialog *emission_file_dialog; SceneTreeDialog *emission_tree_dialog; ConfirmationDialog *err_dialog; diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp index 39251be4683..9cd20ac53ac 100644 --- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp @@ -102,7 +102,7 @@ void ResourcePreloaderEditor::_load_pressed() { for(int i=0;iadd_filter("*."+extensions[i]); - file->set_mode(FileDialog::MODE_OPEN_FILE); + file->set_mode(EditorFileDialog::MODE_OPEN_FILE); file->popup_centered_ratio(); @@ -310,7 +310,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() { paste->set_text("Paste"); hbc->add_child(paste); - file = memnew( FileDialog ); + file = memnew( EditorFileDialog ); add_child(file); diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.h b/tools/editor/plugins/resource_preloader_editor_plugin.h index b3261bd1829..88272bc6032 100644 --- a/tools/editor/plugins/resource_preloader_editor_plugin.h +++ b/tools/editor/plugins/resource_preloader_editor_plugin.h @@ -49,7 +49,7 @@ class ResourcePreloaderEditor : public PanelContainer { bool loading_scene; - FileDialog *file; + EditorFileDialog *file; AcceptDialog *dialog; diff --git a/tools/editor/plugins/rich_text_editor_plugin.cpp b/tools/editor/plugins/rich_text_editor_plugin.cpp index 91eb0a7880a..a0daad854f9 100644 --- a/tools/editor/plugins/rich_text_editor_plugin.cpp +++ b/tools/editor/plugins/rich_text_editor_plugin.cpp @@ -111,10 +111,10 @@ RichTextEditor::RichTextEditor() { options->get_popup()->add_item("Clear",CLEAR); options->get_popup()->connect("item_pressed", this,"_menu_option"); - file_dialog = memnew( FileDialog ); + file_dialog = memnew( EditorFileDialog ); add_child(file_dialog); file_dialog->add_filter("*.txt"); - file_dialog->set_mode(FileDialog::MODE_OPEN_FILE); + file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); file_dialog->connect("file_selected",this,"_file_selected"); } diff --git a/tools/editor/plugins/rich_text_editor_plugin.h b/tools/editor/plugins/rich_text_editor_plugin.h index 653d756d8f2..478dc0d3086 100644 --- a/tools/editor/plugins/rich_text_editor_plugin.h +++ b/tools/editor/plugins/rich_text_editor_plugin.h @@ -53,7 +53,7 @@ class RichTextEditor : public Control { Panel *panel; MenuButton *options; RichTextLabel *node; - FileDialog *file_dialog; + EditorFileDialog *file_dialog; void _file_selected(const String& p_path); void _menu_option(int p_option); diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index bb9d1f9dd03..cf9a6c41a45 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -350,13 +350,13 @@ SampleLibraryEditor::SampleLibraryEditor() { _delete = memnew( Button ); - file = memnew( FileDialog ); + file = memnew( EditorFileDialog ); add_child(file); List extensions; ResourceLoader::get_recognized_extensions_for_type("Sample",&extensions); for(int i=0;iadd_filter("*."+extensions[i]); - file->set_mode(FileDialog::MODE_OPEN_FILES); + file->set_mode(EditorFileDialog::MODE_OPEN_FILES); _delete->set_pos(Point2( 65, 5 )); _delete->set_size( Size2(1,1 ) ); diff --git a/tools/editor/plugins/sample_library_editor_plugin.h b/tools/editor/plugins/sample_library_editor_plugin.h index 70c7fed068c..2770ca2d9a9 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.h +++ b/tools/editor/plugins/sample_library_editor_plugin.h @@ -54,7 +54,7 @@ class SampleLibraryEditor : public Panel { Button *_delete; Tree *tree; - FileDialog *file; + EditorFileDialog *file; ConfirmationDialog *dialog; diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp index 7fdfac2578c..e90087efda2 100644 --- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp @@ -115,7 +115,7 @@ void SpriteFramesEditor::_load_pressed() { for(int i=0;iadd_filter("*."+extensions[i]); - file->set_mode(FileDialog::MODE_OPEN_FILES); + file->set_mode(EditorFileDialog::MODE_OPEN_FILES); file->popup_centered_ratio(); @@ -435,7 +435,7 @@ SpriteFramesEditor::SpriteFramesEditor() { _delete = memnew( Button ); hbc->add_child(_delete); - file = memnew( FileDialog ); + file = memnew( EditorFileDialog ); add_child(file); diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.h b/tools/editor/plugins/sprite_frames_editor_plugin.h index ffd35f37557..969d7b1ce3c 100644 --- a/tools/editor/plugins/sprite_frames_editor_plugin.h +++ b/tools/editor/plugins/sprite_frames_editor_plugin.h @@ -54,7 +54,7 @@ class SpriteFramesEditor : public PanelContainer { int sel; - FileDialog *file; + EditorFileDialog *file; AcceptDialog *dialog; diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 128ff949e15..55e8f164d6f 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -408,7 +408,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { if (p_option==POPUP_CREATE_TEMPLATE) { - file_dialog->set_mode(FileDialog::MODE_SAVE_FILE); + file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); file_dialog->set_current_path("custom.theme"); file_dialog->popup_centered_ratio(); return; @@ -734,7 +734,7 @@ ThemeEditor::ThemeEditor() { fd_button->set_text("Open File Dialog"); panel->add_child(fd_button); - test_file_dialog = memnew( FileDialog ); + test_file_dialog = memnew( EditorFileDialog ); panel->add_child(test_file_dialog); fd_button->connect("pressed", this,"_open_file_dialog"); @@ -804,7 +804,7 @@ ThemeEditor::ThemeEditor() { add_del_dialog->get_ok()->connect("pressed", this,"_dialog_cbk"); - file_dialog = memnew( FileDialog ); + file_dialog = memnew( EditorFileDialog ); file_dialog->add_filter("*.theme ; Theme File"); add_child(file_dialog); file_dialog->connect("file_selected",this,"_save_template_cbk"); diff --git a/tools/editor/plugins/theme_editor_plugin.h b/tools/editor/plugins/theme_editor_plugin.h index 37f5ad6129f..40c7ad81869 100644 --- a/tools/editor/plugins/theme_editor_plugin.h +++ b/tools/editor/plugins/theme_editor_plugin.h @@ -48,7 +48,7 @@ class ThemeEditor : public Control { VBoxContainer *main_vb; Ref theme; - FileDialog *file_dialog; + EditorFileDialog *file_dialog; double time_left; diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index ab27ac7fa96..e38c672a3ea 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -563,7 +563,7 @@ void ProjectExportDialog::_update_group_list() { TreeItem *ti = groups->create_item(r); ti->set_text(0,E->get()); - ti->add_button(0,get_icon("Del","EditorIcons")); + ti->add_button(0,get_icon("Remove","EditorIcons")); if (E->get()==current) { ti->select(0); } @@ -1342,9 +1342,9 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { expopt="--,Export,Bundle"; - file_export = memnew( FileDialog ); + file_export = memnew( EditorFileDialog ); add_child(file_export); - file_export->set_access(FileDialog::ACCESS_FILESYSTEM); + file_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_export->set_current_dir( EditorSettings::get_singleton()->get("global/default_project_export_path") ); file_export->set_title("Export Project"); @@ -1361,8 +1361,8 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { file_export_password->set_editable(false); file_export->get_vbox()->add_margin_child("Password:",file_export_password); - pck_export = memnew( FileDialog ); - pck_export->set_access(FileDialog::ACCESS_FILESYSTEM); + pck_export = memnew( EditorFileDialog ); + pck_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); pck_export->set_current_dir( EditorSettings::get_singleton()->get("global/default_project_export_path") ); pck_export->set_title("Export Project PCK"); pck_export->connect("file_selected", this,"_export_action_pck"); diff --git a/tools/editor/project_export.h b/tools/editor/project_export.h index 08d19e1751f..c88233ae01f 100644 --- a/tools/editor/project_export.h +++ b/tools/editor/project_export.h @@ -33,7 +33,7 @@ #include "scene/gui/control.h" #include "scene/gui/tree.h" #include "scene/gui/label.h" -#include "scene/gui/file_dialog.h" +#include "tools/editor/editor_file_dialog.h" #include "scene/gui/button.h" #include "scene/gui/dialogs.h" #include "scene/gui/tab_container.h" @@ -80,8 +80,8 @@ private: Tree * tree; - FileDialog *pck_export; - FileDialog *file_export; + EditorFileDialog *pck_export; + EditorFileDialog *file_export; CheckButton *file_export_check; LineEdit *file_export_password; diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 08a1191f41d..fea9c705ef4 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -415,7 +415,7 @@ void ProjectSettings::_update_actions() { item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); item->set_text(0,name); item->add_button(0,get_icon("Add","EditorIcons"),1); - item->add_button(0,get_icon("Del","EditorIcons"),2); + item->add_button(0,get_icon("Remove","EditorIcons"),2); item->set_custom_bg_color(0,get_color("prop_subsection","Editor")); item->set_editable(0,true); item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED); @@ -483,7 +483,7 @@ void ProjectSettings::_update_actions() { action->set_icon(0,get_icon("JoyAxis","EditorIcons")); } break; } - action->add_button(0,get_icon("Del","EditorIcons"),2); + action->add_button(0,get_icon("Remove","EditorIcons"),2); action->set_metadata(0,i); } } @@ -1450,9 +1450,9 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { translation_list->set_v_size_flags(SIZE_EXPAND_FILL); tmc->add_child(translation_list); - translation_file_open=memnew( FileDialog ); + translation_file_open=memnew( EditorFileDialog ); add_child(translation_file_open); - translation_file_open->set_mode(FileDialog::MODE_OPEN_FILE); + translation_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE); translation_file_open->connect("file_selected",this,"_translation_add"); } @@ -1477,9 +1477,9 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { tmc->add_child(translation_remap); translation_remap->connect("button_pressed",this,"_translation_res_delete"); - translation_res_file_open=memnew( FileDialog ); + translation_res_file_open=memnew( EditorFileDialog ); add_child(translation_res_file_open); - translation_res_file_open->set_mode(FileDialog::MODE_OPEN_FILE); + translation_res_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE); translation_res_file_open->connect("file_selected",this,"_translation_res_add"); thb = memnew( HBoxContainer); @@ -1507,9 +1507,9 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { translation_remap_options->connect("item_edited",this,"_translation_res_option_changed"); translation_remap_options->connect("button_pressed",this,"_translation_res_option_delete"); - translation_res_option_file_open=memnew( FileDialog ); + translation_res_option_file_open=memnew( EditorFileDialog ); add_child(translation_res_option_file_open); - translation_res_option_file_open->set_mode(FileDialog::MODE_OPEN_FILE); + translation_res_option_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE); translation_res_option_file_open->connect("file_selected",this,"_translation_res_option_add"); } @@ -1548,9 +1548,9 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { autoload_list->set_v_size_flags(SIZE_EXPAND_FILL); avb->add_margin_child("List:",autoload_list,true); - autoload_file_open=memnew( FileDialog ); + autoload_file_open=memnew( EditorFileDialog ); add_child(autoload_file_open); - autoload_file_open->set_mode(FileDialog::MODE_OPEN_FILE); + autoload_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE); autoload_file_open->connect("file_selected",this,"_autoload_file_callback"); autoload_list->set_columns(2); diff --git a/tools/editor/project_settings.h b/tools/editor/project_settings.h index 8e40407d3e8..7c91254764a 100644 --- a/tools/editor/project_settings.h +++ b/tools/editor/project_settings.h @@ -67,19 +67,19 @@ class ProjectSettings : public AcceptDialog { InputEvent last_wait_for_key; - FileDialog *translation_file_open; + EditorFileDialog *translation_file_open; Tree *translation_list; Button *translation_res_option_add_button; - FileDialog *translation_res_file_open; - FileDialog *translation_res_option_file_open; + EditorFileDialog *translation_res_file_open; + EditorFileDialog *translation_res_option_file_open; Tree *translation_remap; Tree *translation_remap_options; Tree *autoload_list; - FileDialog *autoload_file_open; + EditorFileDialog *autoload_file_open; LineEdit *autoload_add_name; LineEdit *autoload_add_path; diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 559267dc073..98e0df77f7c 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -83,7 +83,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { switch(p_which) { case OBJ_MENU_LOAD: { - file->set_mode(FileDialog::MODE_OPEN_FILE); + file->set_mode(EditorFileDialog::MODE_OPEN_FILE); List extensions; String type=(hint==PROPERTY_HINT_RESOURCE_TYPE)?hint_text:String(); @@ -908,11 +908,11 @@ void CustomPropertyEditor::_action_pressed(int p_which) { if (p_which==0) { if (hint==PROPERTY_HINT_FILE) - file->set_access(FileDialog::ACCESS_RESOURCES); + file->set_access(EditorFileDialog::ACCESS_RESOURCES); else - file->set_access(FileDialog::ACCESS_FILESYSTEM); + file->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - file->set_mode(FileDialog::MODE_OPEN_FILE); + file->set_mode(EditorFileDialog::MODE_OPEN_FILE); file->clear_filters(); file->clear_filters(); @@ -946,10 +946,10 @@ void CustomPropertyEditor::_action_pressed(int p_which) { if (p_which==0) { if (hint==PROPERTY_HINT_DIR) - file->set_access(FileDialog::ACCESS_RESOURCES); + file->set_access(EditorFileDialog::ACCESS_RESOURCES); else - file->set_access(FileDialog::ACCESS_FILESYSTEM); - file->set_mode(FileDialog::MODE_OPEN_DIR); + file->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + file->set_mode(EditorFileDialog::MODE_OPEN_DIR); file->clear_filters(); file->popup_centered_ratio(); } else { @@ -1001,8 +1001,8 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } } else if (p_which==1) { - file->set_access(FileDialog::ACCESS_RESOURCES); - file->set_mode(FileDialog::MODE_OPEN_FILE); + file->set_access(EditorFileDialog::ACCESS_RESOURCES); + file->set_mode(EditorFileDialog::MODE_OPEN_FILE); List extensions; String type=(hint==PROPERTY_HINT_RESOURCE_TYPE)?hint_text:String(); @@ -1081,8 +1081,8 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } else if (p_which==1) { - file->set_access(FileDialog::ACCESS_RESOURCES); - file->set_mode(FileDialog::MODE_OPEN_FILE); + file->set_access(EditorFileDialog::ACCESS_RESOURCES); + file->set_mode(EditorFileDialog::MODE_OPEN_FILE); List extensions; ImageLoader::get_recognized_extensions(&extensions); @@ -1612,7 +1612,7 @@ CustomPropertyEditor::CustomPropertyEditor() { color_picker->connect("color_changed",this,"_color_changed"); set_as_toplevel(true); - file = memnew ( FileDialog ); + file = memnew ( EditorFileDialog ); add_child(file); file->hide(); diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index 164643afaa6..de5cac87110 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -32,7 +32,7 @@ #include "scene/gui/tree.h" #include "scene/gui/button.h" #include "scene/gui/label.h" -#include "scene/gui/file_dialog.h" +#include "tools/editor/editor_file_dialog.h" #include "scene/gui/dialogs.h" #include "scene/gui/color_picker.h" #include "scene/gui/menu_button.h" @@ -75,7 +75,7 @@ class CustomPropertyEditor : public Popup { PopupMenu *menu; SceneTreeDialog *scene_tree; - FileDialog *file; + EditorFileDialog *file; ConfirmationDialog *error; String name; Variant::Type type; diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 87a13ee9ce8..432f60fa536 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -171,7 +171,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!_validate_no_foreign()) break; - file->set_mode(FileDialog::MODE_OPEN_FILE); + file->set_mode(EditorFileDialog::MODE_OPEN_FILE); List extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions); file->clear_filters(); @@ -484,7 +484,7 @@ void SceneTreeDock::_notification(int p_what) { "MoveDown", "Duplicate", "Reparent", - "Del", + "Remove", }; for(int i=0;iconnect("file_selected",this,"instance"); set_process_unhandled_key_input(true); diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h index e1a4a10e582..34e8a007391 100644 --- a/tools/editor/scene_tree_dock.h +++ b/tools/editor/scene_tree_dock.h @@ -87,7 +87,7 @@ class SceneTreeDock : public VBoxContainer { ConfirmationDialog *delete_dialog; ReparentDialog *reparent_dialog; - FileDialog *file; + EditorFileDialog *file; EditorSubScene *import_subscene_dialog; diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp index 35f7798ed59..bdfb66f0f2f 100644 --- a/tools/editor/script_create_dialog.cpp +++ b/tools/editor/script_create_dialog.cpp @@ -184,7 +184,7 @@ void ScriptCreateDialog::_built_in_pressed() { void ScriptCreateDialog::_browse_path() { - file_browse->set_mode(FileDialog::MODE_SAVE_FILE); + file_browse->set_mode(EditorFileDialog::MODE_SAVE_FILE); file_browse->clear_filters(); List extensions; @@ -365,7 +365,7 @@ ScriptCreateDialog::ScriptCreateDialog() { set_hide_on_ok(false); set_title("Create Script for Node..");; - file_browse = memnew( FileDialog ); + file_browse = memnew( EditorFileDialog ); file_browse->connect("file_selected",this,"_file_selected"); add_child(file_browse); get_ok()->set_text("Create"); diff --git a/tools/editor/script_create_dialog.h b/tools/editor/script_create_dialog.h index 61f5df43410..59fde8fbd5e 100644 --- a/tools/editor/script_create_dialog.h +++ b/tools/editor/script_create_dialog.h @@ -32,7 +32,7 @@ #include "scene/gui/dialogs.h" #include "scene/gui/line_edit.h" #include "scene/gui/option_button.h" -#include "scene/gui/file_dialog.h" +#include "tools/editor/editor_file_dialog.h" #include "scene/gui/check_button.h" class ScriptCreateDialog : public ConfirmationDialog { @@ -44,7 +44,7 @@ class ScriptCreateDialog : public ConfirmationDialog { LineEdit *parent_name; OptionButton *language_menu; LineEdit *file_path; - FileDialog *file_browse; + EditorFileDialog *file_browse; CheckButton *internal; VBoxContainer *path_vb; AcceptDialog *alert;