diff options
75 files changed, 2219 insertions, 214 deletions
diff --git a/core/globals.cpp b/core/globals.cpp index 0315ff0c24..8a7d66b68a 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -1397,6 +1397,13 @@ Globals::Globals() { 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); joyb.joy_button.button_index=JOY_BUTTON_1; diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 7b5ea65a4b..be566471a8 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<uint8_t> &r_buffer) const { @@ -108,10 +108,29 @@ Variant PacketPeer::_bnd_get_var() const { return var; }; +Error PacketPeer::_put_packet(const DVector<uint8_t> &p_buffer) { + return put_packet_buffer(p_buffer); +} +DVector<uint8_t> PacketPeer::_get_packet() const { + + DVector<uint8_t> 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 3448ebde1b..76d1eb22b5 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<uint8_t> &p_buffer); + DVector<uint8_t> _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 ac315fddb7..5e6cefd114 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 4acac957c8..a588643fd9 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 1821b1a750..e83bd39caa 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 827256c2fa..e30333377f 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<<p_bit; + else + mask&=~(1<<p_bit); + set_collision_mask(mask); + +} + +bool Area2D::get_collision_mask_bit(int p_bit) const{ + + return get_collision_mask()&(1<<p_bit); +} + + +void Area2D::set_layer_mask_bit(int p_bit, bool p_value) { + + uint32_t mask = get_layer_mask(); + if (p_value) + mask|=1<<p_bit; + else + mask&=~(1<<p_bit); + set_layer_mask(mask); + +} + +bool Area2D::get_layer_mask_bit(int p_bit) const{ + + return get_layer_mask()&(1<<p_bit); +} + void Area2D::_bind_methods() { @@ -571,6 +604,12 @@ void Area2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask); ObjectTypeDB::bind_method(_MD("get_layer_mask"),&Area2D::get_layer_mask); + ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area2D::set_collision_mask_bit); + ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area2D::get_collision_mask_bit); + + ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area2D::set_layer_mask_bit); + ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area2D::get_layer_mask_bit); + ObjectTypeDB::bind_method(_MD("set_enable_monitoring","enable"),&Area2D::set_enable_monitoring); ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"),&Area2D::is_monitoring_enabled); diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index 0c064f54cd..72b507103a 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -159,6 +159,12 @@ public: void set_layer_mask(uint32_t p_mask); uint32_t get_layer_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; + Array get_overlapping_bodies() const; //function for script Array get_overlapping_areas() const; //function for script diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 3d2917d843..c30921eb69 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -85,6 +85,14 @@ void PhysicsBody2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask); ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask); ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask); + + + ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody2D::set_collision_mask_bit); + ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody2D::get_collision_mask_bit); + + ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody2D::set_layer_mask_bit); + ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody2D::get_layer_mask_bit); + ObjectTypeDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers); ObjectTypeDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers); ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction); @@ -122,6 +130,37 @@ uint32_t PhysicsBody2D::get_collision_mask() const { return collision_mask; } +void PhysicsBody2D::set_collision_mask_bit(int p_bit, bool p_value) { + + uint32_t mask = get_collision_mask(); + if (p_value) + mask|=1<<p_bit; + else + mask&=~(1<<p_bit); + set_collision_mask(mask); + +} +bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const{ + + return get_collision_mask()&(1<<p_bit); +} + + +void PhysicsBody2D::set_layer_mask_bit(int p_bit, bool p_value) { + + uint32_t mask = get_layer_mask(); + if (p_value) + mask|=1<<p_bit; + else + mask&=~(1<<p_bit); + set_layer_mask(mask); + +} + +bool PhysicsBody2D::get_layer_mask_bit(int p_bit) const{ + + return get_layer_mask()&(1<<p_bit); +} PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject2D( Physics2DServer::get_singleton()->body_create(p_mode), false) { diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 03f95959b6..b70fdd59cf 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 9c69520a85..c672d0e94f 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 0000000000..2fd4d810de --- /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<Texture>& 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<Texture>& 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<Texture>& p_icon){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].icon=p_icon; + update(); + shape_changed=true; + + +} +Ref<Texture> ItemList::get_item_icon(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),Ref<Texture>()); + + return items[p_idx].icon; + +} + + +void ItemList::set_item_tag_icon(int p_idx,const Ref<Texture>& p_tag_icon){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].tag_icon=p_tag_icon; + update(); + shape_changed=true; + + +} +Ref<Texture> ItemList::get_item_tag_icon(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),Ref<Texture>()); + + 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<items.size();i++) { + items[i].selected=p_idx==i; + } + + current=p_idx; + } else { + + if (items[p_idx].selectable) { + items[p_idx].selected=true; + } + } + update(); + +} +void ItemList::unselect(int p_idx){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + if (select_mode!=SELECT_MULTI) { + items[p_idx].selected=false; + current=-1; + } else { + items[p_idx].selected=false; + } + update(); + +} +bool ItemList::is_selected(int p_idx) const{ + + ERR_FAIL_INDEX_V(p_idx,items.size(),false); + + return items[p_idx].selected; + +} + +void ItemList::set_current(int p_current) { + ERR_FAIL_INDEX(p_current,items.size()); + + if (select_mode==SELECT_SINGLE) + select(p_current,true); + else { + current=p_current; + update(); + } +} + +int ItemList::get_current() const { + + return current; +} + + +int ItemList::get_item_count() const{ + + return items.size(); +} +void ItemList::remove_item(int p_idx){ + + ERR_FAIL_INDEX(p_idx,items.size()); + + items.remove(p_idx); + update(); + shape_changed=true; + +} + +void ItemList::clear(){ + + items.clear(); + current=-1; + update(); + +} + +void ItemList::set_fixed_column_width(int p_size){ + + ERR_FAIL_COND(p_size<0); + fixed_column_width=p_size; + update(); + shape_changed=true; + +} +int ItemList::get_fixed_column_width() const{ + + return fixed_column_width; +} + +void ItemList::set_max_text_lines(int p_lines){ + + ERR_FAIL_COND(p_lines<1); + max_text_lines=p_lines; + update(); + shape_changed=true; + +} +int ItemList::get_max_text_lines() const{ + + return max_text_lines; +} + +void ItemList::set_max_columns(int p_amount){ + + ERR_FAIL_COND(p_amount<0); + max_columns=p_amount; + update(); +} +int ItemList::get_max_columns() const{ + + return max_columns; +} + +void ItemList::set_select_mode(SelectMode p_mode) { + + select_mode=p_mode; + update(); +} + +ItemList::SelectMode ItemList::get_select_mode() const { + + return select_mode; +} + +void ItemList::set_icon_mode(IconMode p_mode){ + + icon_mode=p_mode; + update(); + shape_changed=true; + +} +ItemList::IconMode ItemList::get_icon_mode() const{ + + return icon_mode; +} + +void ItemList::set_min_icon_size(const Size2& p_size) { + + min_icon_size=p_size; + update(); +} + +Size2 ItemList::get_min_icon_size() const { + + return min_icon_size; +} + + + +void ItemList::_input_event(const InputEvent& p_event) { + if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && p_event.mouse_button.pressed) { + + const InputEventMouseButton &mb = p_event.mouse_button; + + search_string=""; //any mousepress cancels + Vector2 pos(mb.x,mb.y); + Ref<StyleBox> 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<items.size();i++) { + + Rect2 rc = items[i].rect_cache; + if (i%current_columns==current_columns-1) { + rc.size.width=get_size().width; //not right but works + } + + if (rc.has_point(pos)) { + closest=i; + break; + } + + float dist = rc.distance_to(pos); + if (dist<closest_dist) { + closest=i; + closest_dist=dist; + } + } + + if (closest!=-1) { + + int i = closest; + + if (select_mode==SELECT_MULTI && items[i].selected && mb.mod.command) { + unselect(i); + emit_signal("multi_selected",i,false); + } else if (select_mode==SELECT_MULTI && mb.mod.shift && current>=0 && current<items.size() && current!=i) { + + int from = current; + int to = i; + if (i<current) { + SWAP(from,to); + } + for(int j=from;j<=to;j++) { + bool selected = !items[j].selected; + select(j,false); + if (selected) + emit_signal("multi_selected",i,true); + } + } else { + bool selected = !items[i].selected; + select(i,select_mode==SELECT_SINGLE || !mb.mod.command); + if (selected) { + if (select_mode==SELECT_SINGLE) { + emit_signal("item_selected",i); + } else + emit_signal("multi_selected",i,true); + } + + if (/*select_mode==SELECT_SINGLE &&*/ mb.doubleclick) { + + emit_signal("item_activated",i); + + } + + + } + + + return; + } + } + if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_UP && p_event.mouse_button.pressed) { + + scroll_bar->set_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 (diff<int(Globals::get_singleton()->get("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 (diff<int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec"))*2) { + + for(int i=current+1;i<items.size();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<items.size()-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_page_up")) { + + search_string=""; //any mousepress cancels + + for(int i=4;i>0;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<items.size()) { + if (items[current].selectable && !items[current].selected) { + select(current,false); + emit_signal("multi_selected",current,true); + } else if (items[current].selected) { + unselect(current); + emit_signal("multi_selected",current,false); + } + } + } else if (p_event.is_action("ui_accept")) { + search_string=""; //any mousepress cance + + if (current>=0 && current<items.size()) { + emit_signal("item_activated",current); + } + } else if (p_event.type==InputEvent::KEY) { + + if (p_event.key.unicode) { + + uint64_t now = OS::get_singleton()->get_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<items.size();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; + } + } + + } + + } + } + + + + +} + +void ItemList::ensure_current_is_visible() { + + if (current>=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<StyleBox> 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<StyleBox> sbsel = has_focus()?get_stylebox("selected_focus"):get_stylebox("selected"); + Ref<StyleBox> cursor = has_focus()?get_stylebox("cursor"):get_stylebox("cursor_unfocused"); + + Ref<Font> 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<int> line_size_cache; + Vector<int> 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;i<items.size();i++) { + + Size2 minsize; + if (items[i].icon.is_valid()) { + minsize=items[i].icon->get_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;i<items.size();i++) { + + if (current_columns>1 && 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 (i<items.size()-1) + separators.push_back(ofs.y+max_h+vseparation/2); + ofs.x=0; + ofs.y+=max_h+vseparation; + col=0; + max_h=0; + } + } + + if (all_fit) { + float max = MAX(page,ofs.y+max_h); + scroll_bar->set_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;i<items.size();i++) { + + + Rect2 rcache = items[i].rect_cache; + + if (!clip.intersects(rcache)) + continue; + + + if (current_columns==1) { + rcache.size.width = width-rcache.pos.x; + } + if (items[i].selected) { + Rect2 r=rcache; + r.pos+=base_ofs; + + r.pos.x-=sbsel->get_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 = j<ss?font->get_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<ss;j++) { + + if (j==line_limit_cache[line]) { + line++; + ofs=0; + if (line>=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;i<separators.size();i++) { + draw_line(Vector2(bg->get_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<StyleBox> 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<items.size();i++) { + + Rect2 rc = items[i].rect_cache; + if (i%current_columns==current_columns-1) { + rc.size.width=get_size().width; //not right but works + } + + if (rc.has_point(pos)) { + closest=i; + break; + } + + float dist = rc.distance_to(pos); + if (dist<closest_dist) { + closest=i; + closest_dist=dist; + } + } + + if (closest!=-1) { + if (items[closest].tooltip!="") { + return items[closest].tooltip; + } + if (items[closest].text!="") { + return items[closest].text; + } + } + + return Control::get_tooltip(p_pos); + + +} + + +void ItemList::_bind_methods(){ + + ObjectTypeDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Ref<Texture>()),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 0000000000..6bbb416970 --- /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<Texture> icon; + Ref<Texture> tag_icon; + String text; + bool selectable; + bool selected; + bool disabled; + Variant metadata; + String tooltip; + + Rect2 rect_cache; + }; + + int current; + + bool shape_changed; + + Vector<Item> items; + Vector<int> 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<Texture>& p_texture=Ref<Texture>(),bool p_selectable=true); + void add_icon_item(const Ref<Texture>& 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<Texture>& p_icon); + Ref<Texture> 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<Texture>& p_tag_icon); + Ref<Texture> 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 687410d192..f78481b745 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<HButtonArray>(); ObjectTypeDB::register_type<VButtonArray>(); ObjectTypeDB::register_type<TextureProgress>(); - + ObjectTypeDB::register_type<ItemList>(); #ifndef ADVANCED_GUI_DISABLED @@ -335,6 +336,7 @@ void register_scene_types() { ObjectTypeDB::register_type<LineEdit>(); ObjectTypeDB::register_type<PopupMenu>(); ObjectTypeDB::register_type<Tree>(); + ObjectTypeDB::register_type<TextEdit>(); ObjectTypeDB::register_virtual_type<TreeItem>(); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index d43ffd2130..62fa01f587 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<StyleBoxTexture> tree_selected = make_stylebox( selection_png,4,4,4,4,8,0,8,0); - Ref<StyleBoxTexture> tree_selected_oof = make_stylebox( selection_oof_png,4,4,4,4,8,0,8,0); + Ref<StyleBoxTexture> 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<StyleBoxTexture> item_selected = make_stylebox( selection_png,4,4,4,4,8,2,8,2); + Ref<StyleBoxTexture> 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 5e6bad41aa..a8421acff8 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<String> 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<String>::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 359f807ae4..e3508e4493 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<String> EditorFileDialog::get_selected_files() const { Vector<String> 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;i<item_list->get_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<Texture> folder = get_icon("folder","FileDialog"); + recent->clear(); + + + bool res = access==ACCESS_RESOURCES; + Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs(); + for(int i=0;i<recentd.size();i++) { + bool cres = recentd[i].begins_with("res://"); + if (cres!=res) + continue; + String name = recentd[i]; + if (res && name=="res://") { + name="/"; + } else { + name=name.get_file()+"/"; + } + + //print_line("file: "+name); + recent->add_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<Texture>& p_preview, const Variant& p_udata) { + + if (display_mode==DISPLAY_LIST || p_preview.is_null()) + return; + + for(int i=0;i<item_list->get_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<Texture>()); + } + } } void EditorFileDialog::_thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) { @@ -108,8 +171,13 @@ void EditorFileDialog::_thumbnail_done(const String& p_path,const Ref<Texture>& 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<String> files; - while(ti) { - - files.push_back( fbase.plus_file(ti->get_text(0)) ); - ti=tree->get_next_selected(ti); + for(int i=0;i<item_list->get_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); + } + +} - TreeItem *ti=tree->get_selected(); - if (!ti) +void EditorFileDialog::_item_dc_selected(int p_item) { + + + 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<Texture> folder_thumbnail; + Ref<Texture> 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<ImageTexture> folder = get_icon("FolderBig","EditorIcons"); + Image img = folder->get_data(); + img.resize(thumbnail_size,thumbnail_size); + Ref<ImageTexture> resized_folder = Ref<ImageTexture>( 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<ImageTexture> file = get_icon("FileBig","EditorIcons"); + Image img = file->get_data(); + img.resize(thumbnail_size,thumbnail_size); + Ref<ImageTexture> resized_file = Ref<ImageTexture>( 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<Texture> folder = get_icon("folder","FileDialog"); List<String> files; List<String> 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<Texture> 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;i<favorites->get_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 (i<favorites->get_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<String> 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 && current<favorites->get_item_count()) { + Vector<String> 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 && current<favorites->get_item_count()-1) { + Vector<String> 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<Texture> star = get_icon("Favorites","EditorIcons"); + favorites->clear(); + + favorite->set_pressed(false); + + + Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs(); + for(int i=0;i<favorited.size();i++) { + bool cres = favorited[i].begins_with("res://"); + if (cres!=res) + continue; + String name = favorited[i]; + + bool setthis = name==current; + + if (res && name=="res://") { + name="/"; + } else { + name=name.get_file()+"/"; + } + + + //print_line("file: "+name); + favorites->add_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<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs(); + + bool found = false; + for(int i=0;i<favorited.size();i++) { + bool cres = favorited[i].begins_with("res://"); + if (cres!=res) + continue; + + if (favorited[i]==cd) { + found=true; + break; + } + } + + if (found) { + favorited.erase(cd); + favorite->set_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<String> 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<String> recent = EditorSettings::get_singleton()->get_recent_dirs(); + + const int max=20; + int count=0; + bool res=dir.begins_with("res://"); + + for(int i=0;i<recent.size();i++) { + bool cres=recent[i].begins_with("res://"); + if (recent[i]==dir || (res==cres && count>max)) { + 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 72b8848788..6cfd970516 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 <reduzio@gmail.com> */ @@ -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<String> local_history; + int local_history_pos; + void _push_history(); Vector<String> 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(); - virtual void _post_popup(); + 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<Texture> preview,Variant udata) preview null if could not load + void _thumbnail_result(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata); void _thumbnail_done(const String& p_path,const Ref<Texture>& 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 ae083db0ff..d741087a9f 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 9b7d8d227e..86f6661e8a 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<Texture>& 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<Texture Ref<Texture> 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<Texture>(); //could not guess type @@ -68,7 +68,7 @@ Ref<Texture> 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<Texture> 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<Texture> 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 f8b96eca22..aadae75597 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 2fac05753a..361a86b88e 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<String>& 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;i<favorite_dirs.size();i++) + f->store_line(favorite_dirs[i]); + memdelete(f); + } + +} + +Vector<String> EditorSettings::get_favorite_dirs() const { + + return favorite_dirs; +} + + +void EditorSettings::set_recent_dirs(const Vector<String>& 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;i<recent_dirs.size();i++) + f->store_line(recent_dirs[i]); + memdelete(f); + } +} + +Vector<String> 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 1594719a92..6b7e6eb989 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<String> favorite_dirs; + Vector<String> 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<String,Plugin>& get_plugins() const { return plugins; } @@ -125,6 +131,14 @@ public: void add_property_hint(const PropertyInfo& p_hint); + void set_favorite_dirs(const Vector<String>& p_favorite_dirs); + Vector<String> get_favorite_dirs() const; + + void set_recent_dirs(const Vector<String>& p_recent_dirs); + Vector<String> 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 49385daeaa..2a6eba2554 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<String> 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 9d78dab2a2..dfd6c531e2 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<Node*> *p_to_reown); diff --git a/tools/editor/icons/icon_arrow_left.png b/tools/editor/icons/icon_arrow_left.png Binary files differnew file mode 100644 index 0000000000..b72ac2a10d --- /dev/null +++ b/tools/editor/icons/icon_arrow_left.png diff --git a/tools/editor/icons/icon_arrow_left_disabled.png b/tools/editor/icons/icon_arrow_left_disabled.png Binary files differnew file mode 100644 index 0000000000..f1f9d0f988 --- /dev/null +++ b/tools/editor/icons/icon_arrow_left_disabled.png diff --git a/tools/editor/icons/icon_arrow_right.png b/tools/editor/icons/icon_arrow_right.png Binary files differnew file mode 100644 index 0000000000..d0a48b01ac --- /dev/null +++ b/tools/editor/icons/icon_arrow_right.png diff --git a/tools/editor/icons/icon_arrow_right_disabled.png b/tools/editor/icons/icon_arrow_right_disabled.png Binary files differnew file mode 100644 index 0000000000..840cd0da0a --- /dev/null +++ b/tools/editor/icons/icon_arrow_right_disabled.png diff --git a/tools/editor/icons/icon_arrow_up.png b/tools/editor/icons/icon_arrow_up.png Binary files differnew file mode 100644 index 0000000000..10aac0e0f6 --- /dev/null +++ b/tools/editor/icons/icon_arrow_up.png diff --git a/tools/editor/icons/icon_arrow_up_disabled.png b/tools/editor/icons/icon_arrow_up_disabled.png Binary files differnew file mode 100644 index 0000000000..fb46aa1373 --- /dev/null +++ b/tools/editor/icons/icon_arrow_up_disabled.png diff --git a/tools/editor/icons/icon_favorites.png b/tools/editor/icons/icon_favorites.png Binary files differindex da4713d032..4a3b575f95 100644 --- a/tools/editor/icons/icon_favorites.png +++ b/tools/editor/icons/icon_favorites.png diff --git a/tools/editor/icons/icon_file_big.png b/tools/editor/icons/icon_file_big.png Binary files differnew file mode 100644 index 0000000000..887a4ee05c --- /dev/null +++ b/tools/editor/icons/icon_file_big.png diff --git a/tools/editor/icons/icon_file_list.png b/tools/editor/icons/icon_file_list.png Binary files differnew file mode 100644 index 0000000000..e5e9213e61 --- /dev/null +++ b/tools/editor/icons/icon_file_list.png diff --git a/tools/editor/icons/icon_file_thumbnail.png b/tools/editor/icons/icon_file_thumbnail.png Binary files differnew file mode 100644 index 0000000000..c32be5e8f8 --- /dev/null +++ b/tools/editor/icons/icon_file_thumbnail.png diff --git a/tools/editor/icons/icon_folder_big.png b/tools/editor/icons/icon_folder_big.png Binary files differnew file mode 100644 index 0000000000..988e070f98 --- /dev/null +++ b/tools/editor/icons/icon_folder_big.png diff --git a/tools/editor/icons/icon_item_list.png b/tools/editor/icons/icon_item_list.png Binary files differnew file mode 100644 index 0000000000..f930e7ecaa --- /dev/null +++ b/tools/editor/icons/icon_item_list.png diff --git a/tools/editor/icons/icon_remove.png b/tools/editor/icons/icon_remove.png Binary files differindex 10e56d5bb8..f0f814e304 100644 --- a/tools/editor/icons/icon_remove.png +++ b/tools/editor/icons/icon_remove.png diff --git a/tools/editor/icons/icon_remove_small.png b/tools/editor/icons/icon_remove_small.png Binary files differnew file mode 100644 index 0000000000..e0903689cf --- /dev/null +++ b/tools/editor/icons/icon_remove_small.png diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 375333ddf6..10a3877529 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "editor_font_import_plugin.h" #include "scene/gui/dialogs.h" -#include "scene/gui/file_dialog.h" +#include "tools/editor/editor_file_dialog.h" #include "tools/editor/editor_node.h" #include "os/file_access.h" #include "editor_atlas.h" @@ -379,8 +379,8 @@ class EditorFontImportDialog : public ConfirmationDialog { OBJ_TYPE(EditorFontImportDialog, ConfirmationDialog); - LineEditFileChooser *source; - LineEditFileChooser *dest; + EditorLineEditFileChooser *source; + EditorLineEditFileChooser *dest; SpinBox *font_size; LineEdit *test_string; ColorPickerButton *test_color; @@ -612,9 +612,9 @@ public: hbc->add_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<String> fl; Ref<Font> 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 7d6f400ccc..2e5a6f8a81 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 fa472ed033..9491f957c3 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 2ce5f3a5a7..99dcf4ed28 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;i<ScriptServer::get_language_count();i++) { @@ -1152,7 +1152,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce } - script_select->set_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 3add30d81e..7549a4d32d 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 6d59b52fb5..d152d71af4 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 9a93eed969..05b12543d2 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<String> 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 5c9dc6cab8..9f0413088d 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<Texture> 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 2df9377daf..382bc44726 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 beb67c7196..bd29530c7a 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 7d243b8a65..c118485083 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<String> 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 70ccef2add..583ddf6e14 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 629b4fdc64..fdf534a3a8 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<String> ext; ImageLoader::get_recognized_extensions(&ext); for(List<String>::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 0c355a8c8c..dba0bb4dae 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 3431220526..f6f01d82ca 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 cc13b4f2a9..92756af1f6 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 39251be468..9cd20ac53a 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;i<extensions.size();i++) file->add_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 b3261bd182..88272bc603 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 91eb0a7880..a0daad854f 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 653d756d8f..478dc0d308 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 bb9d1f9dd0..cf9a6c41a4 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<String> extensions; ResourceLoader::get_recognized_extensions_for_type("Sample",&extensions); for(int i=0;i<extensions.size();i++) file->add_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 70c7fed068..2770ca2d9a 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 7fdfac2578..e90087efda 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;i<extensions.size();i++) file->add_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 ffd35f3755..969d7b1ce3 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 128ff949e1..55e8f164d6 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 37f5ad6129..40c7ad8186 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> 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 ab27ac7fa9..e38c672a3e 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 08d19e1751..c88233ae01 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 08a1191f41..fea9c705ef 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 8e40407d3e..7c91254764 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 559267dc07..98e0df77f7 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<String> 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<String> 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<String> 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 164643afaa..de5cac8711 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 87a13ee9ce..432f60fa53 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<String> 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;i<TOOL_BUTTON_MAX;i++) @@ -1355,7 +1355,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec accept = memnew( AcceptDialog ); add_child(accept); - file = memnew( FileDialog ); + file = memnew( EditorFileDialog ); add_child(file); file->connect("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 e1a4a10e58..34e8a00739 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 35f7798ed5..bdfb66f0f2 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<String> 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 61f5df4341..59fde8fbd5 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; |