diff options
Diffstat (limited to 'scene')
42 files changed, 541 insertions, 100 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 52ae5d2954..b7b99f935a 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -118,10 +118,10 @@ Matrix32 Camera2D::get_camera_transform() { - if (smoothing>0.0) { + if (smoothing_enabled) { float c = smoothing*get_fixed_process_delta_time(); - smoothed_camera_pos = ((new_camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos; + smoothed_camera_pos = ((camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos; ret_camera_pos=smoothed_camera_pos; // camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing; } else { @@ -440,6 +440,27 @@ float Camera2D::get_h_offset() const{ } +void Camera2D::_set_old_smoothing(float p_val) { + //compatibility + if (p_val>0) { + smoothing_enabled=true; + set_follow_smoothing(p_val); + } + +} + +void Camera2D::set_enable_follow_smoothing(bool p_enabled) { + + smoothing_enabled=p_enabled; + +} + +bool Camera2D::is_follow_smoothing_enabled() const { + + return smoothing_enabled; +} + + void Camera2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset); @@ -489,14 +510,17 @@ void Camera2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing); ObjectTypeDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing); + ObjectTypeDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing); + ObjectTypeDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled); + ObjectTypeDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll); + ObjectTypeDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing); ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset")); ADD_PROPERTY( PropertyInfo(Variant::INT,"anchor_mode",PROPERTY_HINT_ENUM,"Fixed TopLeft,Drag Center"),_SCS("set_anchor_mode"),_SCS("get_anchor_mode")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"rotating"),_SCS("set_rotating"),_SCS("is_rotating")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),_SCS("_set_current"),_SCS("is_current")); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") ); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),_SCS("set_zoom"),_SCS("get_zoom") ); ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT); @@ -507,6 +531,12 @@ void Camera2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing/enable"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") ); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing/speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") ); + + //compatibility + ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing",PROPERTY_HINT_NONE,"",0),_SCS("_set_old_smoothing"),_SCS("get_follow_smoothing") ); + ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT); ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP); ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT); @@ -535,8 +565,9 @@ Camera2D::Camera2D() { drag_margin[MARGIN_BOTTOM]=0.2; camera_pos=Vector2(); first=true; + smoothing_enabled=false; - smoothing=0.0; + smoothing=5.0; zoom = Vector2(1, 1); h_drag_enabled=true; diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 79d84f48d0..dcf98d4295 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -59,6 +59,7 @@ protected: bool rotating; bool current; float smoothing; + bool smoothing_enabled; int limit[4]; float drag_margin[4]; @@ -73,6 +74,8 @@ protected: void _make_current(Object *p_which); void _set_current(bool p_current); + + void _set_old_smoothing(float p_enable); protected: virtual Matrix32 get_camera_transform(); @@ -108,6 +111,9 @@ public: void set_h_offset(float p_offset); float get_h_offset() const; + void set_enable_follow_smoothing(bool p_enabled); + bool is_follow_smoothing_enabled() const; + void set_follow_smoothing(float p_speed); float get_follow_smoothing() const; diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 357aaa225b..295a57d033 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -309,6 +309,15 @@ void CanvasItem::hide() { _change_notify("visibility/visible"); } +void CanvasItem::set_hidden(bool p_hidden) { + + if (hidden == p_hidden) { + return; + } + + _set_visible_(!p_hidden); +} + Variant CanvasItem::edit_get_state() const { @@ -1043,6 +1052,7 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden); ObjectTypeDB::bind_method(_MD("show"),&CanvasItem::show); ObjectTypeDB::bind_method(_MD("hide"),&CanvasItem::hide); + ObjectTypeDB::bind_method(_MD("set_hidden","hidden"),&CanvasItem::set_hidden); ObjectTypeDB::bind_method(_MD("update"),&CanvasItem::update); @@ -1146,6 +1156,8 @@ Matrix32 CanvasItem::get_canvas_transform() const { if (canvas_layer) return canvas_layer->get_transform(); + else if (get_parent()->cast_to<CanvasItem>()) + return get_parent()->cast_to<CanvasItem>()->get_canvas_transform(); else return get_viewport()->get_canvas_transform(); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 4885256c64..667fedc956 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -190,6 +190,7 @@ public: bool is_hidden() const; void show(); void hide(); + void set_hidden(bool p_hidden); void update(); diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 1479cb7881..616d3da7c9 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -113,6 +113,12 @@ void CollisionPolygon2D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { unparenting=false; can_update_body=get_tree()->is_editor_hint(); + if (!get_tree()->is_editor_hint()) { + //display above all else + set_z_as_relative(false); + set_z(VS::CANVAS_ITEM_Z_MAX-1); + } + } break; case NOTIFICATION_EXIT_TREE: { can_update_body=false; diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index 85751fc735..56f68ae634 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -77,6 +77,11 @@ void CollisionShape2D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { unparenting=false; can_update_body=get_tree()->is_editor_hint(); + if (!get_tree()->is_editor_hint()) { + //display above all else + set_z_as_relative(false); + set_z(VS::CANVAS_ITEM_Z_MAX-1); + } } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { @@ -120,6 +125,7 @@ void CollisionShape2D::_notification(int p_what) { rect=Rect2(); + Color draw_col=get_tree()->get_debug_collisions_color(); shape->draw(get_canvas_item(),draw_col); diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 1df936535f..adb2904a0a 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -111,6 +111,19 @@ real_t Joint2D::get_bias() const{ return bias; } +void Joint2D::set_exclude_nodes_from_collision(bool p_enable) { + + if (exclude_from_collision==p_enable) + return; + exclude_from_collision=p_enable; + _update_joint(); +} + +bool Joint2D::get_exclude_nodes_from_collision() const{ + + return exclude_from_collision; +} + void Joint2D::_bind_methods() { @@ -124,9 +137,14 @@ void Joint2D::_bind_methods() { ObjectTypeDB::bind_method( _MD("set_bias","bias"), &Joint2D::set_bias ); ObjectTypeDB::bind_method( _MD("get_bias"), &Joint2D::get_bias ); + ObjectTypeDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision ); + ObjectTypeDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision ); + ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_a"), _SCS("set_node_a"),_SCS("get_node_a") ); ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_b"), _SCS("set_node_b"),_SCS("get_node_b") ); ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias/bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), _SCS("set_bias"),_SCS("get_bias") ); + ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") ); + } @@ -135,6 +153,7 @@ void Joint2D::_bind_methods() { Joint2D::Joint2D() { bias=0; + exclude_from_collision=true; } /////////////////////////////////////////////////////////////////////////////// @@ -173,7 +192,10 @@ RID PinJoint2D::_configure_joint() { SWAP(body_a,body_b); } else if (body_b) { //add a collision exception between both - Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid()); + if (get_exclude_nodes_from_collision()) + Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid()); + else + Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid()); } RID pj = Physics2DServer::get_singleton()->pin_joint_create(get_global_transform().get_origin(),body_a->get_rid(),body_b?body_b->get_rid():RID()); Physics2DServer::get_singleton()->pin_joint_set_param(pj, Physics2DServer::PIN_JOINT_SOFTNESS, softness); @@ -245,7 +267,11 @@ RID GrooveJoint2D::_configure_joint(){ if (!body_a || !body_b) return RID(); - Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid()); + + if (get_exclude_nodes_from_collision()) + Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid()); + else + Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid()); Matrix32 gt = get_global_transform(); Vector2 groove_A1 = gt.get_origin(); @@ -338,7 +364,10 @@ RID DampedSpringJoint2D::_configure_joint(){ if (!body_a || !body_b) return RID(); - Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid()); + if (get_exclude_nodes_from_collision()) + Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid()); + else + Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid()); Matrix32 gt = get_global_transform(); Vector2 anchor_A = gt.get_origin(); diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h index 908e3a158e..d468f3a6b5 100644 --- a/scene/2d/joints_2d.h +++ b/scene/2d/joints_2d.h @@ -42,6 +42,8 @@ class Joint2D : public Node2D { NodePath b; real_t bias; + bool exclude_from_collision; + protected: @@ -62,6 +64,9 @@ public: void set_bias(real_t p_bias); real_t get_bias() const; + void set_exclude_nodes_from_collision(bool p_enable); + bool get_exclude_nodes_from_collision() const; + RID get_joint() const { return joint; } Joint2D(); diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 852a6fb46b..a2112c7d37 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -333,7 +333,7 @@ void Light2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale")); ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy"),_SCS("set_energy"),_SCS("get_energy")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix"),_SCS("set_mode"),_SCS("get_mode")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),_SCS("set_mode"),_SCS("get_mode")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height"),_SCS("set_height"),_SCS("get_height")); ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min")); ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max")); @@ -349,6 +349,7 @@ void Light2D::_bind_methods() { BIND_CONSTANT( MODE_ADD ); BIND_CONSTANT( MODE_SUB ); BIND_CONSTANT( MODE_MIX ); + BIND_CONSTANT( MODE_MASK ); } diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index bf61868bac..0828d9ac33 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -11,6 +11,7 @@ public: MODE_ADD, MODE_SUB, MODE_MIX, + MODE_MASK, }; private: diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 167b637bdc..1d48a9c8a0 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -32,6 +32,8 @@ #include "method_bind_ext.inc" #include "os/os.h" + + int TileMap::_get_quadrant_size() const { if (y_sort_mode) @@ -299,6 +301,7 @@ void TileMap::_update_dirty_quadrants() { q.occluder_instances.clear(); Ref<CanvasItemMaterial> prev_material; RID prev_canvas_item; + RID prev_debug_canvas_item; for(int i=0;i<q.cells.size();i++) { @@ -319,6 +322,7 @@ void TileMap::_update_dirty_quadrants() { Ref<CanvasItemMaterial> mat = tile_set->tile_get_material(c.id); RID canvas_item; + RID debug_canvas_item; if (prev_canvas_item==RID() || prev_material!=mat) { @@ -331,11 +335,24 @@ void TileMap::_update_dirty_quadrants() { vs->canvas_item_set_transform( canvas_item, xform ); q.canvas_items.push_back(canvas_item); + if (debug_shapes) { + + debug_canvas_item=vs->canvas_item_create(); + vs->canvas_item_set_parent( debug_canvas_item, canvas_item ); + vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item,false); + vs->canvas_item_set_z(debug_canvas_item,VS::CANVAS_ITEM_Z_MAX-1); + q.canvas_items.push_back(debug_canvas_item); + prev_debug_canvas_item=debug_canvas_item; + } + prev_canvas_item=canvas_item; prev_material=mat; } else { canvas_item=prev_canvas_item; + if (debug_shapes) { + debug_canvas_item=prev_debug_canvas_item; + } } @@ -407,9 +424,8 @@ void TileMap::_update_dirty_quadrants() { _fix_cell_transform(xform,c,shape_ofs+center_ofs,s); - if (debug_shapes) { - vs->canvas_item_add_set_transform(canvas_item,xform); - shape->draw(canvas_item,debug_collision_color); + if (debug_canvas_item) { + shape->draw(debug_canvas_item,debug_collision_color); } ps->body_add_shape(q.body,shape->get_rid(),xform); @@ -417,9 +433,6 @@ void TileMap::_update_dirty_quadrants() { } } - if (debug_shapes) { - vs->canvas_item_add_set_transform(canvas_item,Matrix32()); - } if (navigation) { Ref<NavigationPolygon> navpoly = tile_set->tile_get_navigation_polygon(c.id); @@ -452,6 +465,7 @@ void TileMap::_update_dirty_quadrants() { VS::get_singleton()->canvas_light_occluder_set_transform(orid,get_global_transform() * xform); VS::get_singleton()->canvas_light_occluder_set_polygon(orid,occluder->get_rid()); VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid,get_canvas()); + VS::get_singleton()->canvas_light_occluder_set_light_mask(orid,occluder_light_mask); Quadrant::Occluder oc; oc.xform=xform; oc.id=orid; @@ -1075,6 +1089,24 @@ Array TileMap::get_used_cells() const { return a; } +void TileMap::set_occluder_light_mask(int p_mask) { + + occluder_light_mask=p_mask; + for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) { + + for (Map<PosKey,Quadrant::Occluder>::Element *F=E->get().occluder_instances.front();F;F=F->next()) { + VisualServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id,occluder_light_mask); + } + } +} + +int TileMap::get_occluder_light_mask() const{ + + return occluder_light_mask; +} + + + void TileMap::_bind_methods() { @@ -1126,6 +1158,9 @@ void TileMap::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce); ObjectTypeDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce); + ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask); + ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask); + ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell); @@ -1160,6 +1195,7 @@ void TileMap::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce")); ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer"),_SCS("get_collision_layer")); ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder/light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask")); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data")); @@ -1197,6 +1233,7 @@ TileMap::TileMap() { use_kinematic=false; navigation=NULL; y_sort_mode=false; + occluder_light_mask=1; fp_adjust=0.00001; tile_origin=TILE_ORIGIN_TOP_LEFT; diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 60534cce15..4676d1ef7a 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -150,6 +150,8 @@ private: TileOrigin tile_origin; + int occluder_light_mask; + void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc); Map<PosKey,Quadrant>::Element *_create_quadrant(const PosKey& p_qk); @@ -187,6 +189,7 @@ public: INVALID_CELL=-1 }; + void set_tileset(const Ref<TileSet>& p_tileset); Ref<TileSet> get_tileset() const; @@ -247,6 +250,9 @@ public: void set_y_sort_mode(bool p_enable); bool is_y_sort_mode_enabled() const; + void set_occluder_light_mask(int p_mask); + int get_occluder_light_mask() const; + void clear(); TileMap(); diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index d61859a3d0..de50484a1e 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -1073,7 +1073,7 @@ Vector3 KinematicBody::move_to(const Vector3& p_position) { return move(p_position-get_global_transform().origin); } -bool KinematicBody::can_move_to(const Vector3& p_position, bool p_discrete) { +bool KinematicBody::can_teleport_to(const Vector3& p_position) { ERR_FAIL_COND_V(!is_inside_tree(),false); PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(get_world()->get_space()); @@ -1089,25 +1089,18 @@ bool KinematicBody::can_move_to(const Vector3& p_position, bool p_discrete) { if (collide_character) mask|=PhysicsDirectSpaceState::TYPE_MASK_CHARACTER_BODY; - Vector3 motion = p_position-get_global_transform().origin; Transform xform=get_global_transform(); - - if (true || p_discrete) { - - xform.origin+=motion; - motion=Vector3(); - } + xform.origin=p_position; Set<RID> exclude; exclude.insert(get_rid()); - //fill exclude list.. for(int i=0;i<get_shape_count();i++) { if (is_shape_set_as_trigger(i)) continue; - bool col = dss->intersect_shape(get_shape(i)->get_rid(), xform * get_shape_transform(i),0,NULL,0,exclude,get_layer_mask(),mask); + bool col = dss->intersect_shape(get_shape(i)->get_rid(), xform * get_shape_transform(i),0,NULL,1,exclude,get_layer_mask(),mask); if (col) return false; } @@ -1205,7 +1198,7 @@ void KinematicBody::_bind_methods() { ObjectTypeDB::bind_method(_MD("move","rel_vec"),&KinematicBody::move); ObjectTypeDB::bind_method(_MD("move_to","position"),&KinematicBody::move_to); - ObjectTypeDB::bind_method(_MD("can_move_to","position"),&KinematicBody::can_move_to); + ObjectTypeDB::bind_method(_MD("can_teleport_to","position"),&KinematicBody::can_teleport_to); ObjectTypeDB::bind_method(_MD("is_colliding"),&KinematicBody::is_colliding); diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 66490ba925..0e63b77118 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -304,7 +304,7 @@ public: Vector3 move(const Vector3& p_motion); Vector3 move_to(const Vector3& p_position); - bool can_move_to(const Vector3& p_position,bool p_discrete=false); + bool can_teleport_to(const Vector3& p_position); bool is_colliding() const; Vector3 get_collision_pos() const; Vector3 get_collision_normal() const; diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp index 0cc72b28e5..f4facb7c3f 100644 --- a/scene/3d/physics_joint.cpp +++ b/scene/3d/physics_joint.cpp @@ -34,8 +34,15 @@ void Joint::_update_joint(bool p_only_free) { if (joint.is_valid()) { - if (ba.is_valid() && bb.is_valid()) - PhysicsServer::get_singleton()->body_remove_collision_exception(ba,bb); + if (ba.is_valid() && bb.is_valid()) { + + if (exclude_from_collision) + PhysicsServer::get_singleton()->body_add_collision_exception(ba,bb); + else + PhysicsServer::get_singleton()->body_remove_collision_exception(ba,bb); + + } + PhysicsServer::get_singleton()->free(joint); joint=RID(); ba=RID(); @@ -144,6 +151,19 @@ void Joint::_notification(int p_what) { } +void Joint::set_exclude_nodes_from_collision(bool p_enable) { + + if (exclude_from_collision==p_enable) + return; + exclude_from_collision=p_enable; + _update_joint(); +} + +bool Joint::get_exclude_nodes_from_collision() const{ + + return exclude_from_collision; +} + void Joint::_bind_methods() { @@ -156,10 +176,16 @@ void Joint::_bind_methods() { ObjectTypeDB::bind_method( _MD("set_solver_priority","priority"), &Joint::set_solver_priority ); ObjectTypeDB::bind_method( _MD("get_solver_priority"), &Joint::get_solver_priority ); + ObjectTypeDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint::set_exclude_nodes_from_collision ); + ObjectTypeDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint::get_exclude_nodes_from_collision ); + ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_a"), _SCS("set_node_a"),_SCS("get_node_a") ); ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_b"), _SCS("set_node_b"),_SCS("get_node_b") ); ADD_PROPERTY( PropertyInfo( Variant::INT, "solver/priority",PROPERTY_HINT_RANGE,"1,8,1"), _SCS("set_solver_priority"),_SCS("get_solver_priority") ); + ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") ); + + } @@ -167,6 +193,7 @@ void Joint::_bind_methods() { Joint::Joint() { + exclude_from_collision=true; solver_priority=1; } diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h index a5f4ea4bdb..3f5a0e91a6 100644 --- a/scene/3d/physics_joint.h +++ b/scene/3d/physics_joint.h @@ -45,6 +45,7 @@ class Joint : public Spatial { NodePath b; int solver_priority; + bool exclude_from_collision; protected: @@ -67,6 +68,9 @@ public: void set_solver_priority(int p_priority); int get_solver_priority() const; + void set_exclude_nodes_from_collision(bool p_enable); + bool get_exclude_nodes_from_collision() const; + RID get_joint() const { return joint; } Joint(); diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index a65f68ed2c..7d48420a83 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -594,6 +594,15 @@ bool Spatial::is_hidden() const{ return !data.visible; } +void Spatial::set_hidden(bool p_hidden) { + + if (data.visible != p_hidden) { + return; + } + + _set_visible_(!p_hidden); +} + void Spatial::_set_visible_(bool p_visible) { if (p_visible) @@ -742,6 +751,7 @@ void Spatial::_bind_methods() { ObjectTypeDB::bind_method(_MD("hide"), &Spatial::hide); ObjectTypeDB::bind_method(_MD("is_visible"), &Spatial::is_visible); ObjectTypeDB::bind_method(_MD("is_hidden"), &Spatial::is_hidden); + ObjectTypeDB::bind_method(_MD("set_hidden","hidden"), &Spatial::set_hidden); ObjectTypeDB::bind_method(_MD("_set_visible_"), &Spatial::_set_visible_); ObjectTypeDB::bind_method(_MD("_is_visible_"), &Spatial::_is_visible_); diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index 7fa6099d7a..b1e3a82868 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -191,6 +191,7 @@ public: void hide(); bool is_visible() const; bool is_hidden() const; + void set_hidden(bool p_hidden); #ifdef TOOLS_ENABLED void set_import_transform(const Transform& p_transform) ; diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index 8cdf4dd039..2ff51d22c4 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -105,6 +105,8 @@ void Container::fit_child_in_rect(Control *p_child,const Rect2& p_rect) { p_child->set_pos(r.pos); p_child->set_size(r.size); + p_child->set_rotation(0); + p_child->set_scale(Vector2(1,1)); } void Container::queue_sort() { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index bd6b8078ff..ec4886a6ac 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -580,8 +580,8 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_DRAW: { - Matrix32 xform; - xform.set_origin(get_pos()); + Matrix32 xform=Matrix32(data.rotation,get_pos()); + xform.scale_basis(data.scale); VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),xform); VisualServer::get_singleton()->canvas_item_set_custom_rect( get_canvas_item(),true, Rect2(Point2(),get_size())); //emit_signal(SceneStringNames::get_singleton()->draw); @@ -1927,6 +1927,7 @@ void Control::set_size(const Size2& p_size) { data.margin[3] = _s2a( y+h, data.anchor[3], ph ); _size_changed(); + } @@ -2412,9 +2413,9 @@ Control::CursorShape Control::get_cursor_shape(const Point2& p_pos) const { Matrix32 Control::get_transform() const { - Matrix32 xf; - xf.set_origin(get_pos()); - return xf; + Matrix32 xform=Matrix32(data.rotation,get_pos()); + xform.scale_basis(data.scale); + return xform; } String Control::_get_tooltip() const { @@ -2728,6 +2729,39 @@ bool Control::is_text_field() const { return false; } + +void Control::_set_rotation_deg(float p_rot) { + set_rotation(Math::deg2rad(p_rot)); +} + +float Control::_get_rotation_deg() const { + return Math::rad2deg(get_rotation()); +} + +void Control::set_rotation(float p_rotation) { + + data.rotation=p_rotation; + update(); + _notify_transform(); +} + +float Control::get_rotation() const{ + + return data.rotation; +} + +void Control::set_scale(const Vector2& p_scale){ + + data.scale=p_scale; + update(); + _notify_transform(); +} +Vector2 Control::get_scale() const{ + + return data.scale; +} + + void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("_window_input_event"),&Control::_window_input_event); @@ -2756,15 +2790,21 @@ void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_size","size"),&Control::set_size); ObjectTypeDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size); ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos); + ObjectTypeDB::bind_method(_MD("set_rotation","rotation"),&Control::set_rotation); + ObjectTypeDB::bind_method(_MD("_set_rotation_deg","rotation"),&Control::_set_rotation_deg); + ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Control::set_scale); ObjectTypeDB::bind_method(_MD("get_margin","margin"),&Control::get_margin); ObjectTypeDB::bind_method(_MD("get_begin"),&Control::get_begin); ObjectTypeDB::bind_method(_MD("get_end"),&Control::get_end); ObjectTypeDB::bind_method(_MD("get_pos"),&Control::get_pos); ObjectTypeDB::bind_method(_MD("get_size"),&Control::get_size); + ObjectTypeDB::bind_method(_MD("get_rotation"),&Control::get_rotation); + ObjectTypeDB::bind_method(_MD("get_scale"),&Control::get_scale); ObjectTypeDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size); ObjectTypeDB::bind_method(_MD("get_parent_area_size"),&Control::get_size); ObjectTypeDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos); ObjectTypeDB::bind_method(_MD("get_rect"),&Control::get_rect); + ObjectTypeDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg); ObjectTypeDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect); ObjectTypeDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false)); @@ -2846,6 +2886,8 @@ void Control::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") ); ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") ); ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") ); + ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect/rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("_set_rotation_deg"),_SCS("_get_rotation_deg") ); + ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect/scale"), _SCS("set_scale"),_SCS("get_scale") ); ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") ); ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT ); ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP ); @@ -2928,6 +2970,8 @@ Control::Control() { data.v_size_flags=SIZE_FILL; data.expand=1; data.pending_min_size_update=false; + data.rotation=0; + data.scale=Vector2(1,1); for (int i=0;i<4;i++) { diff --git a/scene/gui/control.h b/scene/gui/control.h index 4311b299c8..09a4b48e6b 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -107,7 +107,10 @@ private: float margin[4]; AnchorType anchor[4]; - FocusMode focus_mode; + FocusMode focus_mode; + + float rotation; + Vector2 scale; bool pending_resize; @@ -211,6 +214,8 @@ private: void _size_changed(); String _get_tooltip() const; + void _set_rotation_deg(float p_rot); + float _get_rotation_deg() const; protected: bool window_has_modal_stack() const; @@ -299,6 +304,13 @@ public: Rect2 get_rect() const; Rect2 get_global_rect() const; Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the visual server + + void set_rotation(float p_rotation); + float get_rotation() const; + + void set_scale(const Vector2& p_scale); + Vector2 get_scale() const; + void set_area_as_parent_rect(int p_margin=0); @@ -382,7 +394,7 @@ public: void warp_mouse(const Point2& p_to_pos); - virtual bool is_text_field() const; + virtual bool is_text_field() const; Control(); ~Control(); diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index ff94a37be0..3cc5acc1a6 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -77,9 +77,14 @@ void OptionButton::_selected(int p_which) { } } - ERR_FAIL_COND(selid==-1); + if (selid==-1 && p_which>=0 && p_which<popup->get_item_count()) { + _select(p_which,true); + } else { - _select(selid,true); + ERR_FAIL_COND(selid==-1); + + _select(selid,true); + } } diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 20f28ecf10..9dc03272b2 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -370,7 +370,7 @@ void PopupMenu::_input_event(const InputEvent &p_event) { } int over=_get_mouse_over(Point2(m.x,m.y)); - int id = (over<0 || items[over].separator || items[over].disabled)?-1:items[over].ID; + int id = (over<0 || items[over].separator || items[over].disabled)?-1:(items[over].ID>=0?items[over].ID:over); if (id<0) { mouse_over=-1; @@ -524,7 +524,7 @@ void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,i item.icon=p_icon; item.text=p_label; item.accel=p_accel; - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; items.push_back(item); update(); } @@ -533,7 +533,7 @@ void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) { Item item; item.text=XL_MESSAGE(p_label); item.accel=p_accel; - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; items.push_back(item); update(); } @@ -542,7 +542,7 @@ void PopupMenu::add_submenu_item(const String& p_label, const String& p_submenu, Item item; item.text=XL_MESSAGE(p_label); - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; item.submenu=p_submenu; items.push_back(item); update(); @@ -554,7 +554,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_l item.icon=p_icon; item.text=XL_MESSAGE(p_label); item.accel=p_accel; - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; item.checkable=true; items.push_back(item); update(); @@ -564,7 +564,7 @@ void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel) Item item; item.text=XL_MESSAGE(p_label); item.accel=p_accel; - item.ID=(p_ID<0)?idcount++:p_ID; + item.ID=p_ID; item.checkable=true; items.push_back(item); update(); @@ -753,9 +753,11 @@ int PopupMenu::find_item_by_accelerator(uint32_t p_accel) const { void PopupMenu::activate_item(int p_item) { + ERR_FAIL_INDEX(p_item,items.size()); ERR_FAIL_COND(items[p_item].separator); - emit_signal("item_pressed",items[p_item].ID); + int id = items[p_item].ID>=0?items[p_item].ID:p_item; + emit_signal("item_pressed",id); //hide all parent PopupMenue's Node *next = get_parent(); @@ -789,7 +791,7 @@ void PopupMenu::clear() { items.clear(); mouse_over=-1; update(); - idcount=0; + } @@ -937,7 +939,7 @@ void PopupMenu::set_invalidate_click_until_motion() { PopupMenu::PopupMenu() { - idcount=0; + mouse_over=-1; set_focus_mode(FOCUS_ALL); diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index ed78fe6738..30223469a3 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -59,7 +59,6 @@ class PopupMenu : public Popup { Timer *submenu_timer; List<Rect2> autohide_areas; Vector<Item> items; - int idcount; int mouse_over; int submenu_over; Rect2 parent_rect; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index a48136f541..051a8dd018 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -68,6 +68,25 @@ void SpinBox::_line_edit_input(const InputEvent& p_event) { } +void SpinBox::_range_click_timeout() { + + if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { + + int pos_y = Input::get_singleton()->get_mouse_pos().y-get_global_pos().y; + bool up = pos_y < (get_size().height/2); + set_val( get_val() + (up?get_step():-get_step())); + + if (range_click_timer->is_one_shot()) { + range_click_timer->set_wait_time(0.075); + range_click_timer->set_one_shot(false); + range_click_timer->start(); + } + + } else { + range_click_timer->stop(); + } +} + void SpinBox::_input_event(const InputEvent& p_event) { @@ -85,6 +104,10 @@ void SpinBox::_input_event(const InputEvent& p_event) { set_val( get_val() + (up?get_step():-get_step())); + range_click_timer->set_wait_time(0.6); + range_click_timer->set_one_shot(true); + range_click_timer->start(); + } break; case BUTTON_RIGHT: { @@ -112,6 +135,8 @@ void SpinBox::_input_event(const InputEvent& p_event) { if (p_event.type==InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index==1) { //set_default_cursor_shape(CURSOR_ARROW); + range_click_timer->stop(); + if (drag.enabled) { drag.enabled=false; Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); @@ -167,6 +192,7 @@ void SpinBox::_notification(int p_what) { Size2i size = get_size(); updown->draw(ci,Point2i(size.width-updown->get_width(),(size.height-updown->get_height())/2)); + } else if (p_what==NOTIFICATION_FOCUS_EXIT) { @@ -227,6 +253,7 @@ void SpinBox::_bind_methods() { ObjectTypeDB::bind_method(_MD("_line_edit_focus_exit"),&SpinBox::_line_edit_focus_exit); ObjectTypeDB::bind_method(_MD("get_line_edit"),&SpinBox::get_line_edit); ObjectTypeDB::bind_method(_MD("_line_edit_input"),&SpinBox::_line_edit_input); + ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&SpinBox::_range_click_timeout); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"editable"),_SCS("set_editable"),_SCS("is_editable")); @@ -248,4 +275,8 @@ SpinBox::SpinBox() { line_edit->connect("focus_exit",this,"_line_edit_focus_exit",Vector<Variant>(),CONNECT_DEFERRED); line_edit->connect("input_event",this,"_line_edit_input"); drag.enabled=false; + + range_click_timer = memnew( Timer ); + range_click_timer->connect("timeout",this,"_range_click_timeout"); + add_child(range_click_timer); } diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 4c8cb8432a..1b3bc6d817 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -31,6 +31,7 @@ #include "scene/gui/line_edit.h" #include "scene/gui/range.h" +#include "scene/main/timer.h" class SpinBox : public Range { @@ -39,6 +40,9 @@ class SpinBox : public Range { LineEdit *line_edit; int last_w; + Timer *range_click_timer; + void _range_click_timeout(); + void _text_entered(const String& p_string); virtual void _value_changed(double); String prefix; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 78792dc785..29969b65e6 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -29,6 +29,7 @@ #include "text_edit.h" #include "os/keyboard.h" +#include "os/input.h" #include "os/os.h" #include "globals.h" @@ -349,6 +350,29 @@ void TextEdit::_update_scrollbars() { updating_scrolls=false; } +void TextEdit::_click_selection_held() { + + if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode!=Selection::MODE_NONE) { + + Point2 mp = Input::get_singleton()->get_mouse_pos()-get_global_pos(); + + int row,col; + _get_mouse_pos(Point2i(mp.x,mp.y), row,col); + + select(selection.selecting_line,selection.selecting_column,row,col); + + cursor_set_line( row ); + cursor_set_column( col ); + update(); + + click_select_held->start(); + + } else { + + click_select_held->stop(); + } +} + void TextEdit::_notification(int p_what) { @@ -1292,6 +1316,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { update(); } } else { + + if (mb.button_index==BUTTON_LEFT) + click_select_held->stop(); // notify to show soft keyboard notification(NOTIFICATION_FOCUS_ENTER); @@ -1304,16 +1331,18 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (mm.button_mask&BUTTON_MASK_LEFT) { - int row,col; - _get_mouse_pos(Point2i(mm.x,mm.y), row,col); - if (selection.selecting_mode!=Selection::MODE_NONE) { + + int row,col; + _get_mouse_pos(Point2i(mm.x,mm.y), row,col); select(selection.selecting_line,selection.selecting_column,row,col); cursor_set_line( row ); cursor_set_column( col ); update(); + + click_select_held->start(); } @@ -3697,6 +3726,7 @@ void TextEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit); ObjectTypeDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit); ObjectTypeDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op); + ObjectTypeDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held); BIND_CONSTANT( SEARCH_MATCH_CASE ); BIND_CONSTANT( SEARCH_WHOLE_WORDS ); @@ -3811,6 +3841,11 @@ TextEdit::TextEdit() { idle_detect->set_one_shot(true); idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec",3)); idle_detect->connect("timeout", this,"_push_current_op"); + + click_select_held = memnew( Timer ); + add_child(click_select_held); + click_select_held->set_wait_time(0.05); + click_select_held->connect("timeout", this,"_click_selection_held"); #if 0 syntax_coloring=true; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 91369309cf..f8e8ef3b9a 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -219,6 +219,7 @@ class TextEdit : public Control { uint64_t last_dblclk; Timer *idle_detect; + Timer *click_select_held; HScrollBar *h_scroll; VScrollBar *v_scroll; bool updating_scrolls; @@ -240,6 +241,7 @@ class TextEdit : public Control { void adjust_viewport_to_cursor(); void _scroll_moved(double); void _update_scrollbars(); + void _click_selection_held(); void _pre_shift_selection(); void _post_shift_selection(); diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 5b2caecb5b..7e6bf2cbdf 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -145,7 +145,7 @@ void TextureButton::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture); ObjectTypeDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture); ObjectTypeDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask); - ObjectTypeDB::bind_method(_MD("set_scale","scale"),&TextureButton::set_scale); + ObjectTypeDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale); ObjectTypeDB::bind_method(_MD("set_modulate","color"),&TextureButton::set_modulate); ObjectTypeDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture); @@ -154,7 +154,7 @@ void TextureButton::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture); ObjectTypeDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture); ObjectTypeDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask); - ObjectTypeDB::bind_method(_MD("get_scale"),&TextureButton::get_scale); + ObjectTypeDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale); ObjectTypeDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture")); @@ -163,7 +163,7 @@ void TextureButton::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture")); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture")); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ; - ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_scale"), _SCS("get_scale")); + ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale")); ADD_PROPERTYNO(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate")); } @@ -232,14 +232,14 @@ void TextureButton::set_focused_texture(const Ref<Texture>& p_focused) { focused = p_focused; }; -void TextureButton::set_scale(Size2 p_scale) { +void TextureButton::set_texture_scale(Size2 p_scale) { scale=p_scale; minimum_size_changed(); update(); } -Size2 TextureButton::get_scale() const{ +Size2 TextureButton::get_texture_scale() const{ return scale; } diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h index 01924c1c15..49687986c4 100644 --- a/scene/gui/texture_button.h +++ b/scene/gui/texture_button.h @@ -68,8 +68,8 @@ public: Ref<Texture> get_focused_texture() const; Ref<BitMap> get_click_mask() const; - void set_scale(Size2 p_scale); - Size2 get_scale() const; + void set_texture_scale(Size2 p_scale); + Size2 get_texture_scale() const; void set_modulate(const Color& p_modulate); Color get_modulate() const; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 16a12fe407..ee7c0724e3 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1369,7 +1369,40 @@ Rect2 Tree::search_item_rect(TreeItem *p_from, TreeItem *p_item) { } +void Tree::_range_click_timeout() { + if (range_item_last && !range_drag_enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { + + Point2 pos = (Input::get_singleton()->get_mouse_pos()-get_global_pos())-cache.bg->get_offset(); + if (show_column_titles) { + pos.y-=_get_title_button_height(); + + if (pos.y<0) { + range_click_timer->stop(); + return; + } + } + + click_handled=false; + InputModifierState mod = {}; // should be irrelevant.. + + blocked++; + propagate_mouse_event(pos+cache.offset, 0, 0, false, root, BUTTON_LEFT, mod); + blocked--; + + if (range_click_timer->is_one_shot()) { + range_click_timer->set_wait_time(0.05); + range_click_timer->set_one_shot(false); + range_click_timer->start(); + } + + if (!click_handled) + range_click_timer->stop(); + + } else { + range_click_timer->stop(); + } +} int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_doubleclick,TreeItem *p_item,int p_button,const InputModifierState& p_mod) { @@ -1564,9 +1597,25 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ bool up=p_pos.y < (item_h /2); if (p_button==BUTTON_LEFT) { + + if (range_click_timer->get_time_left() == 0) { + + range_item_last=p_item; + range_up_last=up; + + range_click_timer->set_wait_time(0.6); + range_click_timer->set_one_shot(true); + range_click_timer->start(); + + } else if (up != range_up_last) { + + return -1; // break. avoid changing direction on mouse held + } + p_item->set_range( col, c.val + (up?1.0:-1.0) * c.step ); item_edited(col,p_item); + } else if (p_button==BUTTON_RIGHT) { p_item->set_range( col, (up?c.max:c.min) ); @@ -2024,6 +2073,8 @@ void Tree::_input_event(InputEvent p_event) { update_cache(); const InputEventMouseMotion& b=p_event.mouse_motion; + range_click_timer->stop(); + Ref<StyleBox> bg = cache.bg; Point2 pos = Point2(b.x,b.y) - bg->get_offset(); @@ -2031,7 +2082,6 @@ void Tree::_input_event(InputEvent p_event) { Cache::ClickType old_hover = cache.hover_type; int old_index = cache.hover_index; - cache.hover_type=Cache::CLICK_NONE; cache.hover_index=0; if (show_column_titles) { @@ -2108,6 +2158,8 @@ void Tree::_input_event(InputEvent p_event) { if (b.button_index==BUTTON_LEFT) { + range_click_timer->stop(); + if (pressing_for_editor) { if (range_drag_enabled) { @@ -2228,10 +2280,13 @@ void Tree::_input_event(InputEvent p_event) { } break; case BUTTON_WHEEL_UP: { + + range_click_timer->stop(); v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 ); } break; case BUTTON_WHEEL_DOWN: { + range_click_timer->stop(); v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 ); } break; } @@ -3135,6 +3190,7 @@ bool Tree::is_folding_hidden() const { void Tree::_bind_methods() { + ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout); ObjectTypeDB::bind_method(_MD("_input_event"),&Tree::_input_event); ObjectTypeDB::bind_method(_MD("_popup_select"),&Tree::popup_select); ObjectTypeDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter); @@ -3229,6 +3285,10 @@ Tree::Tree() { add_child(h_scroll); add_child(v_scroll); + range_click_timer = memnew( Timer ); + range_click_timer->connect("timeout",this,"_range_click_timeout"); + add_child(range_click_timer); + h_scroll->connect("value_changed", this,"_scroll_moved"); v_scroll->connect("value_changed", this,"_scroll_moved"); text_editor->connect("text_entered", this,"_text_editor_enter"); diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 8fb9b802a1..55ccc16d01 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -127,7 +127,7 @@ friend class Tree; - TreeItem(Tree *p_tree); + TreeItem(Tree *p_tree); void _changed_notify(int p_cell); @@ -301,6 +301,11 @@ friend class TreeItem; Vector<ColumnInfo> columns; + Timer *range_click_timer; + TreeItem *range_item_last; + bool range_up_last; + void _range_click_timeout(); + int compute_item_height(TreeItem *p_item) const; int get_item_height(TreeItem *p_item) const; // void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index d99da5e906..22b19f50b2 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -338,6 +338,13 @@ float VideoPlayer::get_stream_pos() const { return playback->get_pos(); }; +Ref<Texture> VideoPlayer::get_video_texture() { + + if (playback.is_valid()) + return playback->get_texture(); + + return Ref<Texture> (); +} void VideoPlayer::set_autoplay(bool p_enable) { @@ -384,6 +391,8 @@ void VideoPlayer::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec); ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec); + ObjectTypeDB::bind_method(_MD("get_video_texutre:Texture"), &VideoPlayer::get_video_texture ); + ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") ); ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") ); // ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") ); diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index c485e3d6b6..b14d3936b9 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -88,6 +88,8 @@ public: bool has_expand() const; + Ref<Texture> get_video_texture(); + void set_stream(const Ref<VideoStream> &p_stream); Ref<VideoStream> get_stream() const; @@ -110,8 +112,8 @@ public: void set_autoplay(bool p_vol); bool has_autoplay() const; - void set_audio_track(int p_track); - int get_audio_track() const; + void set_audio_track(int p_track); + int get_audio_track() const; void set_buffering_msec(int p_msec); int get_buffering_msec() const; diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp index 97d3fafd58..bf1f298e7a 100644 --- a/scene/resources/color_ramp.cpp +++ b/scene/resources/color_ramp.cpp @@ -26,6 +26,23 @@ ColorRamp::~ColorRamp() { void ColorRamp::_bind_methods() { + + + + + ObjectTypeDB::bind_method(_MD("add_point","offset","color"),&ColorRamp::add_point); + ObjectTypeDB::bind_method(_MD("remove_point","offset","color"),&ColorRamp::remove_point); + + ObjectTypeDB::bind_method(_MD("set_offset","point","offset"),&ColorRamp::set_offset); + ObjectTypeDB::bind_method(_MD("get_offset","point"),&ColorRamp::get_offset); + + ObjectTypeDB::bind_method(_MD("set_color","point","color"),&ColorRamp::set_color); + ObjectTypeDB::bind_method(_MD("get_color","point"),&ColorRamp::get_color); + + ObjectTypeDB::bind_method(_MD("interpolate","offset"),&ColorRamp::get_color_at_offset); + + ObjectTypeDB::bind_method(_MD("get_point_count"),&ColorRamp::get_points_count); + ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets); ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets); @@ -79,6 +96,23 @@ Vector<ColorRamp::Point>& ColorRamp::get_points() { return points; } +void ColorRamp::add_point(float p_offset, const Color& p_color) { + + Point p; + p.offset=p_offset; + p.color=p_color; + is_sorted=false; + points.push_back(p); + +} + +void ColorRamp::remove_point(int p_index) { + + ERR_FAIL_INDEX(p_index,points.size()); + ERR_FAIL_COND(points.size()<=2); + points.remove(p_index); +} + void ColorRamp::set_points(Vector<ColorRamp::Point>& p_points) { points = p_points; is_sorted = false; diff --git a/scene/resources/color_ramp.h b/scene/resources/color_ramp.h index 8f6ba2c3e5..aab5698c2b 100644 --- a/scene/resources/color_ramp.h +++ b/scene/resources/color_ramp.h @@ -32,6 +32,9 @@ public: ColorRamp(); virtual ~ColorRamp(); + void add_point(float p_offset, const Color& p_color); + void remove_point(int p_index); + void set_points(Vector<Point>& points); Vector<Point>& get_points(); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 2d93113b40..aad5e7cfdd 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -462,31 +462,16 @@ void Font::draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,fl void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, const Color& p_modulate,int p_clip_w) const { - Point2 pos=p_pos; - float ofs=0; - VisualServer *vs = VisualServer::get_singleton(); + Vector2 ofs; for (int i=0;i<p_text.length();i++) { - const Character * c = char_map.getptr(p_text[i]); + int width = get_char_size(p_text[i]).width; - if (!c) - continue; - -// if (p_clip_w>=0 && (ofs+c->rect.size.width)>(p_clip_w)) -// break; //width exceeded - - if (p_clip_w>=0 && (ofs+c->rect.size.width)>p_clip_w) + if (p_clip_w>=0 && (ofs.x+width)>p_clip_w) break; //clip - Point2 cpos=pos; - cpos.x+=ofs+c->h_align; - cpos.y-=ascent; - cpos.y+=c->v_align; - ERR_CONTINUE( c->texture_idx<-1 || c->texture_idx>=textures.size()); - if (c->texture_idx!=-1) - textures[c->texture_idx]->draw_rect_region( p_canvas_item, Rect2( cpos, c->rect.size ), c->rect, p_modulate ); - - ofs+=get_char_size(p_text[i],p_text[i+1]).width; + + ofs.x+=draw_char(p_canvas_item,p_pos+ofs,p_text[i],p_text[i+1],p_modulate); } } @@ -494,8 +479,11 @@ float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_ const Character * c = char_map.getptr(p_char); - if (!c) + if (!c) { + if (fallback.is_valid()) + return fallback->draw_char(p_canvas_item,p_pos,p_char,p_next,p_modulate); return 0; + } Point2 cpos=p_pos; cpos.x+=c->h_align; @@ -508,6 +496,16 @@ float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_ return get_char_size(p_char,p_next).width; } +void Font::set_fallback(const Ref<Font> &p_fallback) { + + fallback=p_fallback; +} + +Ref<Font> Font::get_fallback() const{ + + return fallback; +} + void Font::_bind_methods() { ObjectTypeDB::bind_method(_MD("create_from_fnt","path"),&Font::create_from_fnt); @@ -548,6 +546,8 @@ void Font::_bind_methods() { ObjectTypeDB::bind_method(_MD("_set_textures"),&Font::_set_textures); ObjectTypeDB::bind_method(_MD("_get_textures"),&Font::_get_textures); + ObjectTypeDB::bind_method(_MD("set_fallback","fallback"),&Font::set_fallback); + ObjectTypeDB::bind_method(_MD("get_fallback"),&Font::get_fallback); ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "textures", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_textures"), _SCS("_get_textures") ); ADD_PROPERTY( PropertyInfo( Variant::INT_ARRAY, "chars", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_chars"), _SCS("_get_chars") ); @@ -556,6 +556,7 @@ void Font::_bind_methods() { ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_height"), _SCS("get_height") ); ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_ascent"), _SCS("get_ascent") ); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "distance_field" ), _SCS("set_distance_field_hint"), _SCS("is_distance_field_hint") ); + ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE,"Font" ), _SCS("set_fallback"), _SCS("get_fallback") ); } diff --git a/scene/resources/font.h b/scene/resources/font.h index 6728b59f8e..27e3045eaa 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -84,6 +84,7 @@ private: void _set_textures(const Vector<Variant> & p_textures); Vector<Variant> _get_textures() const; + Ref<Font> fallback; protected: static void _bind_methods(); @@ -113,9 +114,13 @@ public: int get_kerning_pair(CharType p_A,CharType p_B) const; Vector<KerningPairKey> get_kerning_pair_keys() const; - _FORCE_INLINE_ Size2 get_char_size(CharType p_char,CharType p_next=0) const; + inline Size2 get_char_size(CharType p_char,CharType p_next=0) const; Size2 get_string_size(const String& p_string) const; + + void set_fallback(const Ref<Font> &p_fallback); + Ref<Font> get_fallback() const; + void clear(); void set_distance_field_hint(bool p_distance_field); @@ -134,8 +139,11 @@ Size2 Font::get_char_size(CharType p_char,CharType p_next) const { const Character * c = char_map.getptr(p_char); - if (!c) + if (!c) { + if (fallback.is_valid()) + return fallback->get_char_size(p_char,p_next); return Size2(); + } Size2 ret(c->advance,c->rect.size.y); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 55bb4e9073..b4ea60cb8d 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -535,6 +535,8 @@ void ShaderMaterial::_shader_changed() { void ShaderMaterial::set_shader(const Ref<Shader>& p_shader) { + ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_MATERIAL); + if (shader.is_valid()) shader->disconnect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed); shader=p_shader; diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 863f2be699..f8283bb5ca 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -509,6 +509,19 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S } } + if (exists && p_node->get_script_instance()) { + //if this is an overriden value by another script, save it anyway + //as the script change will erase it + //https://github.com/godotengine/godot/issues/2958 + + bool valid=false; + p_node->get_script_instance()->get_property_type(name,&valid); + if (valid) { + exists=false; + isdefault=false; + } + } + if (exists && bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) { //exists and did not change diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index 5f41dc2ce8..851083aecf 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -932,6 +932,10 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderText::load_interactive(const void ResourceFormatLoaderText::get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const { + if (p_type=="") { + get_recognized_extensions(p_extensions); + return; + } if (p_type=="PackedScene") p_extensions->push_back("tscn"); diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index a9376faf62..f0a2721016 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -448,31 +448,19 @@ RES ResourceFormatLoaderShader::load(const String &p_path, const String& p_origi void ResourceFormatLoaderShader::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("shader"); + ObjectTypeDB::get_extensions_for_type("Shader", p_extensions); } + bool ResourceFormatLoaderShader::handles_type(const String& p_type) const { - return p_type=="Shader"; + return ObjectTypeDB::is_type(p_type, "Shader"); } String ResourceFormatLoaderShader::get_resource_type(const String &p_path) const { - if (p_path.extension().to_lower()=="shader") + if (p_path.extension().to_lower()=="shd") return "Shader"; return ""; } - - - - - - - - - - - - - |