diff options
Diffstat (limited to 'scene')
69 files changed, 578 insertions, 313 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 26241df660..c2edb173d7 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -223,7 +223,7 @@ void SpriteFrames::_bind_methods() { ClassDB::bind_method(D_METHOD("set_animation_loop", "anim", "loop"), &SpriteFrames::set_animation_loop); ClassDB::bind_method(D_METHOD("get_animation_loop", "anim"), &SpriteFrames::get_animation_loop); - ClassDB::bind_method(D_METHOD("add_frame", "anim", "frame", "atpos"), &SpriteFrames::add_frame, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("add_frame", "anim", "frame", "at_position"), &SpriteFrames::add_frame, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("get_frame_count", "anim"), &SpriteFrames::get_frame_count); ClassDB::bind_method(D_METHOD("get_frame", "anim", "idx"), &SpriteFrames::get_frame); ClassDB::bind_method(D_METHOD("set_frame", "anim", "idx", "txt"), &SpriteFrames::set_frame); diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 9fc6c8d23a..9ee77a710c 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -557,12 +557,12 @@ bool Area2D::is_overriding_audio_bus() const { return audio_bus_override; } -void Area2D::set_audio_bus(const StringName &p_audio_bus) { +void Area2D::set_audio_bus_name(const StringName &p_audio_bus) { audio_bus = p_audio_bus; } -StringName Area2D::get_audio_bus() const { +StringName Area2D::get_audio_bus_name() const { for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { if (AudioServer::get_singleton()->get_bus_name(i) == audio_bus) { @@ -644,8 +644,8 @@ void Area2D::_bind_methods() { ClassDB::bind_method(D_METHOD("overlaps_body", "body"), &Area2D::overlaps_body); ClassDB::bind_method(D_METHOD("overlaps_area", "area"), &Area2D::overlaps_area); - ClassDB::bind_method(D_METHOD("set_audio_bus", "name"), &Area2D::set_audio_bus); - ClassDB::bind_method(D_METHOD("get_audio_bus"), &Area2D::get_audio_bus); + ClassDB::bind_method(D_METHOD("set_audio_bus_name", "name"), &Area2D::set_audio_bus_name); + ClassDB::bind_method(D_METHOD("get_audio_bus_name"), &Area2D::get_audio_bus_name); ClassDB::bind_method(D_METHOD("set_audio_bus_override", "enable"), &Area2D::set_audio_bus_override); ClassDB::bind_method(D_METHOD("is_overriding_audio_bus"), &Area2D::is_overriding_audio_bus); @@ -679,7 +679,7 @@ void Area2D::_bind_methods() { ADD_GROUP("Audio Bus", "audio_bus_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_bus_override"), "set_audio_bus_override", "is_overriding_audio_bus"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus", "get_audio_bus"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus_name", "get_audio_bus_name"); BIND_ENUM_CONSTANT(SPACE_OVERRIDE_DISABLED); BIND_ENUM_CONSTANT(SPACE_OVERRIDE_COMBINE); diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index c56cf651a1..09ccb364e6 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -186,8 +186,8 @@ public: void set_audio_bus_override(bool p_override); bool is_overriding_audio_bus() const; - void set_audio_bus(const StringName &p_audio_bus); - StringName get_audio_bus() const; + void set_audio_bus_name(const StringName &p_audio_bus); + StringName get_audio_bus_name() const; Area2D(); ~Area2D(); diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index b6abe90035..c40aeb764e 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -145,7 +145,7 @@ void AudioStreamPlayer2D::_notification(int p_what) { if (!area2d->is_overriding_audio_bus()) continue; - StringName bus_name = area2d->get_audio_bus(); + StringName bus_name = area2d->get_audio_bus_name(); bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus_name); break; } @@ -284,10 +284,10 @@ bool AudioStreamPlayer2D::is_playing() const { return false; } -float AudioStreamPlayer2D::get_pos() { +float AudioStreamPlayer2D::get_playback_position() { if (stream_playback.is_valid()) { - return stream_playback->get_pos(); + return stream_playback->get_playback_position(); } return 0; @@ -390,12 +390,12 @@ void AudioStreamPlayer2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_volume_db", "volume_db"), &AudioStreamPlayer2D::set_volume_db); ClassDB::bind_method(D_METHOD("get_volume_db"), &AudioStreamPlayer2D::get_volume_db); - ClassDB::bind_method(D_METHOD("play", "from_pos"), &AudioStreamPlayer2D::play, DEFVAL(0.0)); - ClassDB::bind_method(D_METHOD("seek", "to_pos"), &AudioStreamPlayer2D::seek); + ClassDB::bind_method(D_METHOD("play", "from_position"), &AudioStreamPlayer2D::play, DEFVAL(0.0)); + ClassDB::bind_method(D_METHOD("seek", "to_position"), &AudioStreamPlayer2D::seek); ClassDB::bind_method(D_METHOD("stop"), &AudioStreamPlayer2D::stop); ClassDB::bind_method(D_METHOD("is_playing"), &AudioStreamPlayer2D::is_playing); - ClassDB::bind_method(D_METHOD("get_pos"), &AudioStreamPlayer2D::get_pos); + ClassDB::bind_method(D_METHOD("get_playback_position"), &AudioStreamPlayer2D::get_playback_position); ClassDB::bind_method(D_METHOD("set_bus", "bus"), &AudioStreamPlayer2D::set_bus); ClassDB::bind_method(D_METHOD("get_bus"), &AudioStreamPlayer2D::get_bus); diff --git a/scene/2d/audio_stream_player_2d.h b/scene/2d/audio_stream_player_2d.h index 25eff61b76..85104fce21 100644 --- a/scene/2d/audio_stream_player_2d.h +++ b/scene/2d/audio_stream_player_2d.h @@ -72,7 +72,7 @@ public: void seek(float p_seconds); void stop(); bool is_playing() const; - float get_pos(); + float get_playback_position(); void set_bus(const StringName &p_bus); StringName get_bus() const; diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index e39e6fc6da..0d04967f1c 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -452,7 +452,7 @@ float Camera2D::get_drag_margin(Margin p_margin) const { return drag_margin[p_margin]; } -Vector2 Camera2D::get_camera_pos() const { +Vector2 Camera2D::get_camera_position() const { return camera_pos; } @@ -673,7 +673,7 @@ void Camera2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_drag_margin", "margin", "drag_margin"), &Camera2D::set_drag_margin); ClassDB::bind_method(D_METHOD("get_drag_margin", "margin"), &Camera2D::get_drag_margin); - ClassDB::bind_method(D_METHOD("get_camera_pos"), &Camera2D::get_camera_pos); + ClassDB::bind_method(D_METHOD("get_camera_position"), &Camera2D::get_camera_position); ClassDB::bind_method(D_METHOD("get_camera_screen_center"), &Camera2D::get_camera_screen_center); ClassDB::bind_method(D_METHOD("set_zoom", "zoom"), &Camera2D::set_zoom); diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index dfcadf65a6..13b6be3978 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -137,7 +137,7 @@ public: void set_custom_viewport(Node *p_viewport); Node *get_custom_viewport() const; - Vector2 get_camera_pos() const; + Vector2 get_camera_position() const; void force_update_scroll(); void reset_smoothing(); void align(); diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index ec1ea7df38..d9bb6576d9 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -902,7 +902,7 @@ Ref<Material> CanvasItem::get_material() const { return material; } -Vector2 CanvasItem::make_canvas_pos_local(const Vector2 &screen_point) const { +Vector2 CanvasItem::make_canvas_position_local(const Vector2 &screen_point) const { ERR_FAIL_COND_V(!is_inside_tree(), screen_point); @@ -923,7 +923,8 @@ Vector2 CanvasItem::get_global_mouse_position() const { ERR_FAIL_COND_V(!get_viewport(), Vector2()); return get_canvas_transform().affine_inverse().xform(get_viewport()->get_mouse_position()); } -Vector2 CanvasItem::get_local_mouse_pos() const { + +Vector2 CanvasItem::get_local_mouse_position() const { ERR_FAIL_COND_V(!get_viewport(), Vector2()); @@ -976,18 +977,18 @@ void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("draw_polyline", "points", "color", "width", "antialiased"), &CanvasItem::draw_polyline, DEFVAL(1.0), DEFVAL(false)); ClassDB::bind_method(D_METHOD("draw_polyline_colors", "points", "colors", "width", "antialiased"), &CanvasItem::draw_polyline_colors, DEFVAL(1.0), DEFVAL(false)); ClassDB::bind_method(D_METHOD("draw_rect", "rect", "color", "filled"), &CanvasItem::draw_rect, DEFVAL(true)); - ClassDB::bind_method(D_METHOD("draw_circle", "pos", "radius", "color"), &CanvasItem::draw_circle); - ClassDB::bind_method(D_METHOD("draw_texture", "texture", "pos", "modulate", "normal_map"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("draw_circle", "position", "radius", "color"), &CanvasItem::draw_circle); + ClassDB::bind_method(D_METHOD("draw_texture", "texture", "position", "modulate", "normal_map"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("draw_texture_rect", "texture", "rect", "tile", "modulate", "transpose", "normal_map"), &CanvasItem::draw_texture_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true)); ClassDB::bind_method(D_METHOD("draw_style_box", "style_box", "rect"), &CanvasItem::draw_style_box); ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width", "normal_map"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("draw_string", "font", "pos", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1)); - ClassDB::bind_method(D_METHOD("draw_char", "font", "pos", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1))); + ClassDB::bind_method(D_METHOD("draw_string", "font", "position", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("draw_char", "font", "position", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("draw_set_transform", "pos", "rot", "scale"), &CanvasItem::draw_set_transform); + ClassDB::bind_method(D_METHOD("draw_set_transform", "position", "rotation", "scale"), &CanvasItem::draw_set_transform); ClassDB::bind_method(D_METHOD("draw_set_transform_matrix", "xform"), &CanvasItem::draw_set_transform_matrix); ClassDB::bind_method(D_METHOD("get_transform"), &CanvasItem::get_transform); ClassDB::bind_method(D_METHOD("get_global_transform"), &CanvasItem::get_global_transform); @@ -995,7 +996,7 @@ void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("get_viewport_transform"), &CanvasItem::get_viewport_transform); ClassDB::bind_method(D_METHOD("get_viewport_rect"), &CanvasItem::get_viewport_rect); ClassDB::bind_method(D_METHOD("get_canvas_transform"), &CanvasItem::get_canvas_transform); - ClassDB::bind_method(D_METHOD("get_local_mouse_pos"), &CanvasItem::get_local_mouse_pos); + ClassDB::bind_method(D_METHOD("get_local_mouse_position"), &CanvasItem::get_local_mouse_position); ClassDB::bind_method(D_METHOD("get_global_mouse_position"), &CanvasItem::get_global_mouse_position); ClassDB::bind_method(D_METHOD("get_canvas"), &CanvasItem::get_canvas); ClassDB::bind_method(D_METHOD("get_world_2d"), &CanvasItem::get_world_2d); @@ -1013,8 +1014,7 @@ void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("set_notify_transform", "enable"), &CanvasItem::set_notify_transform); ClassDB::bind_method(D_METHOD("is_transform_notification_enabled"), &CanvasItem::is_transform_notification_enabled); - ClassDB::bind_method(D_METHOD("make_canvas_pos_local", "screen_point"), - &CanvasItem::make_canvas_pos_local); + ClassDB::bind_method(D_METHOD("make_canvas_position_local", "screen_point"), &CanvasItem::make_canvas_position_local); ClassDB::bind_method(D_METHOD("make_input_local", "event"), &CanvasItem::make_input_local); BIND_VMETHOD(MethodInfo("_draw")); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 5a0a9c6e6a..1afbd150a2 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -298,10 +298,10 @@ public: bool get_use_parent_material() const; Ref<InputEvent> make_input_local(const Ref<InputEvent> &p_event) const; - Vector2 make_canvas_pos_local(const Vector2 &screen_point) const; + Vector2 make_canvas_position_local(const Vector2 &screen_point) const; Vector2 get_global_mouse_position() const; - Vector2 get_local_mouse_pos() const; + Vector2 get_local_mouse_position() const; void set_notify_local_transform(bool p_enable); bool is_local_transform_notification_enabled() const; diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index d8cef5b937..9131223ff3 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -68,12 +68,12 @@ PoolVector<Vector2> Line2D::get_points() const { return _points; } -void Line2D::set_point_pos(int i, Vector2 pos) { +void Line2D::set_point_position(int i, Vector2 pos) { _points.set(i, pos); update(); } -Vector2 Line2D::get_point_pos(int i) const { +Vector2 Line2D::get_point_position(int i) const { return _points.get(i); } @@ -270,12 +270,12 @@ void Line2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_points", "points"), &Line2D::set_points); ClassDB::bind_method(D_METHOD("get_points"), &Line2D::get_points); - ClassDB::bind_method(D_METHOD("set_point_pos", "i", "pos"), &Line2D::set_point_pos); - ClassDB::bind_method(D_METHOD("get_point_pos", "i"), &Line2D::get_point_pos); + ClassDB::bind_method(D_METHOD("set_point_position", "i", "position"), &Line2D::set_point_position); + ClassDB::bind_method(D_METHOD("get_point_position", "i"), &Line2D::get_point_position); ClassDB::bind_method(D_METHOD("get_point_count"), &Line2D::get_point_count); - ClassDB::bind_method(D_METHOD("add_point", "pos"), &Line2D::add_point); + ClassDB::bind_method(D_METHOD("add_point", "position"), &Line2D::add_point); ClassDB::bind_method(D_METHOD("remove_point", "i"), &Line2D::remove_point); ClassDB::bind_method(D_METHOD("set_width", "width"), &Line2D::set_width); diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h index 36aadfd265..6426484f02 100644 --- a/scene/2d/line_2d.h +++ b/scene/2d/line_2d.h @@ -60,8 +60,8 @@ public: void set_points(const PoolVector<Vector2> &p_points); PoolVector<Vector2> get_points() const; - void set_point_pos(int i, Vector2 pos); - Vector2 get_point_pos(int i) const; + void set_point_position(int i, Vector2 pos); + Vector2 get_point_position(int i) const; int get_point_count() const; diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 0c7685a858..e62b59dd4d 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -414,7 +414,7 @@ void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("_get_rotd"), &Node2D::_get_rotd); ClassDB::bind_method(D_METHOD("_set_rotd", "degrees"), &Node2D::_set_rotd); - ClassDB::bind_method(D_METHOD("set_position", "pos"), &Node2D::set_position); + ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation); ClassDB::bind_method(D_METHOD("set_rotation_in_degrees", "degrees"), &Node2D::set_rotation_in_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Node2D::set_scale); @@ -431,7 +431,7 @@ void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("global_translate", "offset"), &Node2D::global_translate); ClassDB::bind_method(D_METHOD("apply_scale", "ratio"), &Node2D::apply_scale); - ClassDB::bind_method(D_METHOD("set_global_position", "pos"), &Node2D::set_global_position); + ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Node2D::set_global_position); ClassDB::bind_method(D_METHOD("get_global_position"), &Node2D::get_global_position); ClassDB::bind_method(D_METHOD("set_global_rotation", "radians"), &Node2D::set_global_rotation); ClassDB::bind_method(D_METHOD("get_global_rotation"), &Node2D::get_global_rotation); diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 9bd5576d91..8413be1ca9 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -43,7 +43,7 @@ void Path2D::_notification(int p_what) { for (int i = 0; i < curve->get_point_count(); i++) { - Vector2 prev_p = curve->get_point_pos(i); + Vector2 prev_p = curve->get_point_position(i); for (int j = 1; j <= 8; j++) { diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index b1cc8c226a..4286d88ab1 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1294,9 +1294,9 @@ void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("get_occluder_light_mask"), &TileMap::get_occluder_light_mask); ClassDB::bind_method(D_METHOD("set_cell", "x", "y", "tile", "flip_x", "flip_y", "transpose"), &TileMap::set_cell, DEFVAL(false), DEFVAL(false), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("set_cellv", "pos", "tile", "flip_x", "flip_y", "transpose"), &TileMap::set_cellv, DEFVAL(false), DEFVAL(false), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("set_cellv", "position", "tile", "flip_x", "flip_y", "transpose"), &TileMap::set_cellv, DEFVAL(false), DEFVAL(false), DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_cell", "x", "y"), &TileMap::get_cell); - ClassDB::bind_method(D_METHOD("get_cellv", "pos"), &TileMap::get_cellv); + ClassDB::bind_method(D_METHOD("get_cellv", "position"), &TileMap::get_cellv); ClassDB::bind_method(D_METHOD("is_cell_x_flipped", "x", "y"), &TileMap::is_cell_x_flipped); ClassDB::bind_method(D_METHOD("is_cell_y_flipped", "x", "y"), &TileMap::is_cell_y_flipped); ClassDB::bind_method(D_METHOD("is_cell_transposed", "x", "y"), &TileMap::is_cell_transposed); @@ -1307,8 +1307,8 @@ void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("get_used_cells_by_id", "id"), &TileMap::get_used_cells_by_id); ClassDB::bind_method(D_METHOD("get_used_rect"), &TileMap::get_used_rect); - ClassDB::bind_method(D_METHOD("map_to_world", "mappos", "ignore_half_ofs"), &TileMap::map_to_world, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("world_to_map", "worldpos"), &TileMap::world_to_map); + ClassDB::bind_method(D_METHOD("map_to_world", "map_position", "ignore_half_ofs"), &TileMap::map_to_world, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("world_to_map", "world_position"), &TileMap::world_to_map); ClassDB::bind_method(D_METHOD("_clear_quadrants"), &TileMap::_clear_quadrants); ClassDB::bind_method(D_METHOD("_recreate_quadrants"), &TileMap::_recreate_quadrants); diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index b8c6a86f55..7bc8c9e89e 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -611,10 +611,10 @@ bool AudioStreamPlayer3D::is_playing() const { return false; } -float AudioStreamPlayer3D::get_pos() { +float AudioStreamPlayer3D::get_playback_position() { if (stream_playback.is_valid()) { - return stream_playback->get_pos(); + return stream_playback->get_playback_position(); } return 0; @@ -802,12 +802,12 @@ void AudioStreamPlayer3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_max_db", "max_db"), &AudioStreamPlayer3D::set_max_db); ClassDB::bind_method(D_METHOD("get_max_db"), &AudioStreamPlayer3D::get_max_db); - ClassDB::bind_method(D_METHOD("play", "from_pos"), &AudioStreamPlayer3D::play, DEFVAL(0.0)); - ClassDB::bind_method(D_METHOD("seek", "to_pos"), &AudioStreamPlayer3D::seek); + ClassDB::bind_method(D_METHOD("play", "from_position"), &AudioStreamPlayer3D::play, DEFVAL(0.0)); + ClassDB::bind_method(D_METHOD("seek", "to_position"), &AudioStreamPlayer3D::seek); ClassDB::bind_method(D_METHOD("stop"), &AudioStreamPlayer3D::stop); ClassDB::bind_method(D_METHOD("is_playing"), &AudioStreamPlayer3D::is_playing); - ClassDB::bind_method(D_METHOD("get_pos"), &AudioStreamPlayer3D::get_pos); + ClassDB::bind_method(D_METHOD("get_playback_position"), &AudioStreamPlayer3D::get_playback_position); ClassDB::bind_method(D_METHOD("set_bus", "bus"), &AudioStreamPlayer3D::set_bus); ClassDB::bind_method(D_METHOD("get_bus"), &AudioStreamPlayer3D::get_bus); diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h index b729b55f7e..2c2d4610c8 100644 --- a/scene/3d/audio_stream_player_3d.h +++ b/scene/3d/audio_stream_player_3d.h @@ -127,7 +127,7 @@ public: void seek(float p_seconds); void stop(); bool is_playing() const; - float get_pos(); + float get_playback_position(); void set_bus(const StringName &p_bus); StringName get_bus() const; diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index c121ef4566..1c0633fba7 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -145,9 +145,9 @@ void CollisionObject::_bind_methods() { ClassDB::bind_method(D_METHOD("shape_owner_clear_shapes", "owner_id"), &CollisionObject::shape_owner_clear_shapes); ClassDB::bind_method(D_METHOD("shape_find_owner", "shape_index"), &CollisionObject::shape_find_owner); - BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_pos"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx"))); + BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_position"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx"))); - ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_pos"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx"))); + ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_position"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx"))); ADD_SIGNAL(MethodInfo("mouse_entered")); ADD_SIGNAL(MethodInfo("mouse_exited")); diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp index 64d3f4fcab..11f7efe066 100644 --- a/scene/3d/immediate_geometry.cpp +++ b/scene/3d/immediate_geometry.cpp @@ -149,7 +149,7 @@ void ImmediateGeometry::_bind_methods() { ClassDB::bind_method(D_METHOD("set_color", "color"), &ImmediateGeometry::set_color); ClassDB::bind_method(D_METHOD("set_uv", "uv"), &ImmediateGeometry::set_uv); ClassDB::bind_method(D_METHOD("set_uv2", "uv"), &ImmediateGeometry::set_uv2); - ClassDB::bind_method(D_METHOD("add_vertex", "pos"), &ImmediateGeometry::add_vertex); + ClassDB::bind_method(D_METHOD("add_vertex", "position"), &ImmediateGeometry::add_vertex); ClassDB::bind_method(D_METHOD("add_sphere", "lats", "lons", "radius", "add_uv"), &ImmediateGeometry::add_sphere, DEFVAL(true)); ClassDB::bind_method(D_METHOD("end"), &ImmediateGeometry::end); ClassDB::bind_method(D_METHOD("clear"), &ImmediateGeometry::clear); diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 6551deabf2..005ea1f8d1 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -825,7 +825,7 @@ void RigidBody::_bind_methods() { ClassDB::bind_method(D_METHOD("is_using_continuous_collision_detection"), &RigidBody::is_using_continuous_collision_detection); ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidBody::set_axis_velocity); - ClassDB::bind_method(D_METHOD("apply_impulse", "pos", "impulse"), &RigidBody::apply_impulse); + ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &RigidBody::apply_impulse); ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidBody::set_sleeping); ClassDB::bind_method(D_METHOD("is_sleeping"), &RigidBody::is_sleeping); diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 91fe426b99..0dfd80ca90 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -651,7 +651,7 @@ void Spatial::look_at(const Vector3 &p_target, const Vector3 &p_up_normal) { set_global_transform(lookat); } -void Spatial::look_at_from_pos(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up_normal) { +void Spatial::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up_normal) { Transform lookat; lookat.origin = p_pos; @@ -749,7 +749,7 @@ void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_identity"), &Spatial::set_identity); ClassDB::bind_method(D_METHOD("look_at", "target", "up"), &Spatial::look_at); - ClassDB::bind_method(D_METHOD("look_at_from_pos", "pos", "target", "up"), &Spatial::look_at_from_pos); + ClassDB::bind_method(D_METHOD("look_at_from_position", "position", "target", "up"), &Spatial::look_at_from_position); ClassDB::bind_method(D_METHOD("to_local", "global_point"), &Spatial::to_local); ClassDB::bind_method(D_METHOD("to_global", "local_point"), &Spatial::to_global); diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index 3f205ea86b..b912d1f906 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -172,7 +172,7 @@ public: void global_translate(const Vector3 &p_offset); void look_at(const Vector3 &p_target, const Vector3 &p_up_normal); - void look_at_from_pos(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up_normal); + void look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up_normal); Vector3 to_local(Vector3 p_global) const; Vector3 to_global(Vector3 p_local) const; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index be0b652276..cadbd086bc 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1045,7 +1045,7 @@ bool AnimationPlayer::is_valid() const { return (playback.current.from); } -float AnimationPlayer::get_current_animation_pos() const { +float AnimationPlayer::get_current_animation_position() const { ERR_FAIL_COND_V(!playback.current.from, 0); return playback.current.pos; @@ -1238,8 +1238,8 @@ void AnimationPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_root", "path"), &AnimationPlayer::set_root); ClassDB::bind_method(D_METHOD("get_root"), &AnimationPlayer::get_root); - ClassDB::bind_method(D_METHOD("seek", "pos_sec", "update"), &AnimationPlayer::seek, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("get_pos"), &AnimationPlayer::get_current_animation_pos); + ClassDB::bind_method(D_METHOD("seek", "seconds", "update"), &AnimationPlayer::seek, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("get_position"), &AnimationPlayer::get_current_animation_position); ClassDB::bind_method(D_METHOD("find_animation", "animation"), &AnimationPlayer::find_animation); @@ -1248,7 +1248,7 @@ void AnimationPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_animation_process_mode", "mode"), &AnimationPlayer::set_animation_process_mode); ClassDB::bind_method(D_METHOD("get_animation_process_mode"), &AnimationPlayer::get_animation_process_mode); - ClassDB::bind_method(D_METHOD("get_current_animation_pos"), &AnimationPlayer::get_current_animation_pos); + ClassDB::bind_method(D_METHOD("get_current_animation_position"), &AnimationPlayer::get_current_animation_position); ClassDB::bind_method(D_METHOD("get_current_animation_length"), &AnimationPlayer::get_current_animation_length); ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationPlayer::advance); diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index c6e52145a8..bface7aabb 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -279,7 +279,7 @@ public: void seek(float p_time, bool p_update = false); void seek_delta(float p_time, float p_delta); - float get_current_animation_pos() const; + float get_current_animation_position() const; float get_current_animation_length() const; void advance(float p_time); diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 38d0527288..a2a8adb653 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -92,7 +92,7 @@ bool AnimationTreePlayer::_set(const StringName &p_name, const Variant &p_value) Dictionary node = nodes[i]; StringName id = node.get_valid("id"); - Point2 pos = node.get_valid("pos"); + Point2 pos = node.get_valid("position"); NodeType nt = NODE_MAX; String type = node.get_valid("type"); @@ -122,7 +122,7 @@ bool AnimationTreePlayer::_set(const StringName &p_name, const Variant &p_value) if (nt != NODE_OUTPUT) add_node(nt, id); - node_set_pos(id, pos); + node_set_position(id, pos); switch (nt) { case NODE_OUTPUT: { @@ -245,7 +245,7 @@ bool AnimationTreePlayer::_get(const StringName &p_name, Variant &r_ret) const { Dictionary node; node["id"] = E->key(); - node["pos"] = n->pos; + node["position"] = n->pos; switch (n->type) { case NODE_OUTPUT: node["type"] = "output"; break; @@ -1176,7 +1176,7 @@ void AnimationTreePlayer::transition_node_set_current(const StringName &p_node, n->set_current(p_current); } -void AnimationTreePlayer::node_set_pos(const StringName &p_node, const Vector2 &p_pos) { +void AnimationTreePlayer::node_set_position(const StringName &p_node, const Vector2 &p_pos) { ERR_FAIL_COND(!node_map.has(p_node)); node_map[p_node]->pos = p_pos; @@ -1187,7 +1187,7 @@ AnimationTreePlayer::NodeType AnimationTreePlayer::node_get_type(const StringNam ERR_FAIL_COND_V(!node_map.has(p_node), NODE_OUTPUT); return node_map[p_node]->type; } -Point2 AnimationTreePlayer::node_get_pos(const StringName &p_node) const { +Point2 AnimationTreePlayer::node_get_position(const StringName &p_node) const { ERR_FAIL_COND_V(!node_map.has(p_node), Point2()); return node_map[p_node]->pos; @@ -1752,7 +1752,7 @@ void AnimationTreePlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("timescale_node_set_scale", "id", "scale"), &AnimationTreePlayer::timescale_node_set_scale); ClassDB::bind_method(D_METHOD("timescale_node_get_scale", "id"), &AnimationTreePlayer::timescale_node_get_scale); - ClassDB::bind_method(D_METHOD("timeseek_node_seek", "id", "pos_sec"), &AnimationTreePlayer::timeseek_node_seek); + ClassDB::bind_method(D_METHOD("timeseek_node_seek", "id", "seconds"), &AnimationTreePlayer::timeseek_node_seek); ClassDB::bind_method(D_METHOD("transition_node_set_input_count", "id", "count"), &AnimationTreePlayer::transition_node_set_input_count); ClassDB::bind_method(D_METHOD("transition_node_get_input_count", "id"), &AnimationTreePlayer::transition_node_get_input_count); @@ -1767,8 +1767,8 @@ void AnimationTreePlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("transition_node_set_current", "id", "input_idx"), &AnimationTreePlayer::transition_node_set_current); ClassDB::bind_method(D_METHOD("transition_node_get_current", "id"), &AnimationTreePlayer::transition_node_get_current); - ClassDB::bind_method(D_METHOD("node_set_pos", "id", "screen_pos"), &AnimationTreePlayer::node_set_pos); - ClassDB::bind_method(D_METHOD("node_get_pos", "id"), &AnimationTreePlayer::node_get_pos); + ClassDB::bind_method(D_METHOD("node_set_position", "id", "screen_position"), &AnimationTreePlayer::node_set_position); + ClassDB::bind_method(D_METHOD("node_get_position", "id"), &AnimationTreePlayer::node_get_position); ClassDB::bind_method(D_METHOD("remove_node", "id"), &AnimationTreePlayer::remove_node); ClassDB::bind_method(D_METHOD("connect_nodes", "id", "dst_id", "dst_input_idx"), &AnimationTreePlayer::connect_nodes); diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 609430340b..806a4f6604 100644 --- a/scene/animation/animation_tree_player.h +++ b/scene/animation/animation_tree_player.h @@ -417,10 +417,10 @@ public: void transition_node_set_current(const StringName &p_node, int p_current); int transition_node_get_current(const StringName &p_node) const; - void node_set_pos(const StringName &p_node, const Vector2 &p_pos); //for display + void node_set_position(const StringName &p_node, const Vector2 &p_pos); //for display /* GETS */ - Point2 node_get_pos(const StringName &p_node) const; //for display + Point2 node_get_position(const StringName &p_node) const; //for display NodeType node_get_type(const StringName &p_node) const; diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 661d085dfd..14dd39a491 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -193,10 +193,10 @@ bool AudioStreamPlayer::is_playing() const { return false; } -float AudioStreamPlayer::get_pos() { +float AudioStreamPlayer::get_playback_position() { if (stream_playback.is_valid()) { - return stream_playback->get_pos(); + return stream_playback->get_playback_position(); } return 0; @@ -279,12 +279,12 @@ void AudioStreamPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_volume_db", "volume_db"), &AudioStreamPlayer::set_volume_db); ClassDB::bind_method(D_METHOD("get_volume_db"), &AudioStreamPlayer::get_volume_db); - ClassDB::bind_method(D_METHOD("play", "from_pos"), &AudioStreamPlayer::play, DEFVAL(0.0)); - ClassDB::bind_method(D_METHOD("seek", "to_pos"), &AudioStreamPlayer::seek); + ClassDB::bind_method(D_METHOD("play", "from_position"), &AudioStreamPlayer::play, DEFVAL(0.0)); + ClassDB::bind_method(D_METHOD("seek", "to_position"), &AudioStreamPlayer::seek); ClassDB::bind_method(D_METHOD("stop"), &AudioStreamPlayer::stop); ClassDB::bind_method(D_METHOD("is_playing"), &AudioStreamPlayer::is_playing); - ClassDB::bind_method(D_METHOD("get_pos"), &AudioStreamPlayer::get_pos); + ClassDB::bind_method(D_METHOD("get_playback_position"), &AudioStreamPlayer::get_playback_position); ClassDB::bind_method(D_METHOD("set_bus", "bus"), &AudioStreamPlayer::set_bus); ClassDB::bind_method(D_METHOD("get_bus"), &AudioStreamPlayer::get_bus); diff --git a/scene/audio/audio_player.h b/scene/audio/audio_player.h index 4bfa84f766..4bfc44730d 100644 --- a/scene/audio/audio_player.h +++ b/scene/audio/audio_player.h @@ -83,7 +83,7 @@ public: void seek(float p_seconds); void stop(); bool is_playing() const; - float get_pos(); + float get_playback_position(); void set_bus(const StringName &p_bus); StringName get_bus() const; diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 5713a35b7a..04c0817b15 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -39,7 +39,7 @@ void BaseButton::_unpress_group() { if (!button_group.is_valid()) return; - status.pressed = true; + status.pressed = false; for (Set<BaseButton *>::Element *E = button_group->buttons.front(); E; E = E->next()) { if (E->get() == this) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 2d5b54257a..2c01a0e2d1 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -49,7 +49,7 @@ Variant Control::edit_get_state() const { Dictionary s; s["rect"] = get_rect(); - s["rot"] = get_rotation(); + s["rotation"] = get_rotation(); s["scale"] = get_scale(); Array anchors; anchors.push_back(get_anchor(MARGIN_LEFT)); @@ -66,7 +66,7 @@ void Control::edit_set_state(const Variant &p_state) { Rect2 state = s["rect"]; set_position(state.position); set_size(state.size); - set_rotation(s["rot"]); + set_rotation(s["rotation"]); set_scale(s["scale"]); Array anchors = s["anchors"]; set_anchor(MARGIN_LEFT, anchors[0]); @@ -2477,12 +2477,12 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("get_anchor", "margin"), &Control::get_anchor); ClassDB::bind_method(D_METHOD("set_margin", "margin", "offset"), &Control::set_margin); ClassDB::bind_method(D_METHOD("set_anchor_and_margin", "margin", "anchor", "offset", "push_opposite_anchor"), &Control::set_anchor_and_margin, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("set_begin", "pos"), &Control::set_begin); - ClassDB::bind_method(D_METHOD("set_end", "pos"), &Control::set_end); - ClassDB::bind_method(D_METHOD("set_position", "pos"), &Control::set_position); + ClassDB::bind_method(D_METHOD("set_begin", "position"), &Control::set_begin); + ClassDB::bind_method(D_METHOD("set_end", "position"), &Control::set_end); + ClassDB::bind_method(D_METHOD("set_position", "position"), &Control::set_position); ClassDB::bind_method(D_METHOD("set_size", "size"), &Control::set_size); ClassDB::bind_method(D_METHOD("set_custom_minimum_size", "size"), &Control::set_custom_minimum_size); - ClassDB::bind_method(D_METHOD("set_global_position", "pos"), &Control::set_global_position); + ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Control::set_global_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Control::set_rotation); ClassDB::bind_method(D_METHOD("set_rotation_deg", "degrees"), &Control::set_rotation_deg); // TODO: Obsolete this method (old name) properly (GH-4397) @@ -2560,12 +2560,12 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("get_v_grow_direction"), &Control::get_v_grow_direction); ClassDB::bind_method(D_METHOD("set_tooltip", "tooltip"), &Control::set_tooltip); - ClassDB::bind_method(D_METHOD("get_tooltip", "atpos"), &Control::get_tooltip, DEFVAL(Point2())); + ClassDB::bind_method(D_METHOD("get_tooltip", "at_position"), &Control::get_tooltip, DEFVAL(Point2())); ClassDB::bind_method(D_METHOD("_get_tooltip"), &Control::_get_tooltip); ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Control::set_default_cursor_shape); ClassDB::bind_method(D_METHOD("get_default_cursor_shape"), &Control::get_default_cursor_shape); - ClassDB::bind_method(D_METHOD("get_cursor_shape", "pos"), &Control::get_cursor_shape, DEFVAL(Point2())); + ClassDB::bind_method(D_METHOD("get_cursor_shape", "position"), &Control::get_cursor_shape, DEFVAL(Point2())); ClassDB::bind_method(D_METHOD("set_focus_neighbour", "margin", "neighbour"), &Control::set_focus_neighbour); ClassDB::bind_method(D_METHOD("get_focus_neighbour", "margin"), &Control::get_focus_neighbour); @@ -2583,7 +2583,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_drag_forwarding", "target"), &Control::set_drag_forwarding); ClassDB::bind_method(D_METHOD("set_drag_preview", "control"), &Control::set_drag_preview); - ClassDB::bind_method(D_METHOD("warp_mouse", "to_pos"), &Control::warp_mouse); + ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Control::warp_mouse); ClassDB::bind_method(D_METHOD("minimum_size_changed"), &Control::minimum_size_changed); @@ -2593,9 +2593,9 @@ void Control::_bind_methods() { BIND_VMETHOD(MethodInfo("_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); BIND_VMETHOD(MethodInfo(Variant::VECTOR2, "_get_minimum_size")); - BIND_VMETHOD(MethodInfo(Variant::OBJECT, "get_drag_data", PropertyInfo(Variant::VECTOR2, "pos"))); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "can_drop_data", PropertyInfo(Variant::VECTOR2, "pos"), PropertyInfo(Variant::NIL, "data"))); - BIND_VMETHOD(MethodInfo("drop_data", PropertyInfo(Variant::VECTOR2, "pos"), PropertyInfo(Variant::NIL, "data"))); + BIND_VMETHOD(MethodInfo(Variant::OBJECT, "get_drag_data", PropertyInfo(Variant::VECTOR2, "position"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "can_drop_data", PropertyInfo(Variant::VECTOR2, "position"), PropertyInfo(Variant::NIL, "data"))); + BIND_VMETHOD(MethodInfo("drop_data", PropertyInfo(Variant::VECTOR2, "position"), PropertyInfo(Variant::NIL, "data"))); ADD_GROUP("Anchor", "anchor_"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anchor_left", PROPERTY_HINT_RANGE, "0,1,0.01"), "_set_anchor", "get_anchor", MARGIN_LEFT); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 5b00aab2ef..3ffa6d57a4 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -352,14 +352,14 @@ bool GraphEdit::_filter_input(const Point2 &p_point) { for (int j = 0; j < gn->get_connection_output_count(); j++) { - Vector2 pos = gn->get_connection_output_pos(j) + gn->get_position(); + Vector2 pos = gn->get_connection_output_position(j) + gn->get_position(); if (pos.distance_to(p_point) < grab_r) return true; } for (int j = 0; j < gn->get_connection_input_count(); j++) { - Vector2 pos = gn->get_connection_input_pos(j) + gn->get_position(); + Vector2 pos = gn->get_connection_input_position(j) + gn->get_position(); if (pos.distance_to(p_point) < grab_r) { return true; } @@ -386,7 +386,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { for (int j = 0; j < gn->get_connection_output_count(); j++) { - Vector2 pos = gn->get_connection_output_pos(j) + gn->get_position(); + Vector2 pos = gn->get_connection_output_position(j) + gn->get_position(); if (pos.distance_to(mpos) < grab_r) { if (valid_left_disconnect_types.has(gn->get_connection_output_type(j))) { @@ -433,7 +433,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { for (int j = 0; j < gn->get_connection_input_count(); j++) { - Vector2 pos = gn->get_connection_input_pos(j) + gn->get_position(); + Vector2 pos = gn->get_connection_input_position(j) + gn->get_position(); if (pos.distance_to(mpos) < grab_r) { @@ -501,7 +501,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { if (!connecting_out) { for (int j = 0; j < gn->get_connection_output_count(); j++) { - Vector2 pos = gn->get_connection_output_pos(j) + gn->get_position(); + Vector2 pos = gn->get_connection_output_position(j) + gn->get_position(); int type = gn->get_connection_output_type(j); if ((type == connecting_type || valid_connection_types.has(ConnType(type, connecting_type))) && pos.distance_to(mpos) < grab_r) { @@ -516,7 +516,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { for (int j = 0; j < gn->get_connection_input_count(); j++) { - Vector2 pos = gn->get_connection_input_pos(j) + gn->get_position(); + Vector2 pos = gn->get_connection_input_position(j) + gn->get_position(); int type = gn->get_connection_input_type(j); if ((type == connecting_type || valid_connection_types.has(ConnType(type, connecting_type))) && pos.distance_to(mpos) < grab_r) { connecting_target = true; @@ -657,9 +657,9 @@ void GraphEdit::_connections_layer_draw() { continue; } - Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom; + Vector2 frompos = gfrom->get_connection_output_position(E->get().from_port) + gfrom->get_offset() * zoom; Color color = gfrom->get_connection_output_color(E->get().from_port); - Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom; + Vector2 topos = gto->get_connection_input_position(E->get().to_port) + gto->get_offset() * zoom; Color tocolor = gto->get_connection_input_color(E->get().to_port); _draw_cos_line(connections_layer, frompos, topos, color, tocolor); } @@ -682,9 +682,9 @@ void GraphEdit::_top_layer_draw() { ERR_FAIL_COND(!from); Vector2 pos; if (connecting_out) - pos = from->get_connection_output_pos(connecting_index); + pos = from->get_connection_output_position(connecting_index); else - pos = from->get_connection_input_pos(connecting_index); + pos = from->get_connection_input_position(connecting_index); pos += from->get_position(); Vector2 topos; @@ -733,7 +733,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { just_selected = true; // TODO: Remove local mouse pos hack if/when InputEventMouseMotion is fixed to support floats //drag_accum+=Vector2(mm->get_relative().x,mm->get_relative().y); - drag_accum = get_local_mouse_pos() - drag_origin; + drag_accum = get_local_mouse_position() - drag_origin; for (int i = get_child_count() - 1; i >= 0; i--) { GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (gn && gn->is_selected()) { @@ -750,7 +750,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { } if (mm.is_valid() && box_selecting) { - box_selecting_to = get_local_mouse_pos(); + box_selecting_to = get_local_mouse_position(); box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x), MIN(box_selecting_from.y, box_selecting_to.y), @@ -810,7 +810,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (gn) { Rect2 r = gn->get_rect(); r.size *= zoom; - if (r.has_point(get_local_mouse_pos())) + if (r.has_point(get_local_mouse_position())) gn->set_selected(false); } } @@ -848,7 +848,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (gn_selected->is_resizing()) continue; - if (gn_selected->has_point(gn_selected->get_local_mouse_pos())) { + if (gn_selected->has_point(gn_selected->get_local_mouse_position())) { gn = gn_selected; break; } @@ -862,7 +862,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { dragging = true; drag_accum = Vector2(); - drag_origin = get_local_mouse_pos(); + drag_origin = get_local_mouse_position(); just_selected = !gn->is_selected(); if (!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { for (int i = 0; i < get_child_count(); i++) { @@ -888,7 +888,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { return; box_selecting = true; - box_selecting_from = get_local_mouse_pos(); + box_selecting_from = get_local_mouse_position(); if (b->get_control()) { box_selection_mode_aditive = true; previus_selected.clear(); @@ -1167,7 +1167,7 @@ void GraphEdit::_bind_methods() { ADD_SIGNAL(MethodInfo("popup_request", PropertyInfo(Variant::VECTOR2, "p_position"))); ADD_SIGNAL(MethodInfo("duplicate_nodes_request")); ADD_SIGNAL(MethodInfo("node_selected", PropertyInfo(Variant::OBJECT, "node"))); - ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_pos"))); + ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position"))); ADD_SIGNAL(MethodInfo("delete_nodes_request")); ADD_SIGNAL(MethodInfo("_begin_node_move")); ADD_SIGNAL(MethodInfo("_end_node_move")); diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index bef0808fd0..7655363631 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -208,8 +208,11 @@ void GraphNode::_notification(int p_what) { Ref<Texture> close = get_icon("close"); Ref<Texture> resizer = get_icon("resizer"); int close_offset = get_constant("close_offset"); + int close_h_offset = get_constant("close_h_offset"); + Color close_color = get_color("close_color"); Ref<Font> title_font = get_font("title_font"); int title_offset = get_constant("title_offset"); + int title_h_offset = get_constant("title_h_offset"); Color title_color = get_color("title_color"); Point2i icofs = -port->get_size() * 0.5; int edgeofs = get_constant("port_offset"); @@ -236,10 +239,10 @@ void GraphNode::_notification(int p_what) { if (show_close) w -= close->get_width(); - draw_string(title_font, Point2(sb->get_margin(MARGIN_LEFT), -title_font->get_height() + title_font->get_ascent() + title_offset), title, title_color, w); + draw_string(title_font, Point2(sb->get_margin(MARGIN_LEFT) + title_h_offset, -title_font->get_height() + title_font->get_ascent() + title_offset), title, title_color, w); if (show_close) { - Vector2 cpos = Point2(w + sb->get_margin(MARGIN_LEFT), -close->get_height() + close_offset); - draw_texture(close, cpos); + Vector2 cpos = Point2(w + sb->get_margin(MARGIN_LEFT) + close_h_offset, -close->get_height() + close_offset); + draw_texture(close, cpos, close_color); close_rect.position = cpos; close_rect.size = close->get_size(); } else { @@ -515,7 +518,7 @@ int GraphNode::get_connection_output_count() { return conn_output_cache.size(); } -Vector2 GraphNode::get_connection_input_pos(int p_idx) { +Vector2 GraphNode::get_connection_input_position(int p_idx) { if (connpos_dirty) _connpos_update(); @@ -545,7 +548,7 @@ Color GraphNode::get_connection_input_color(int p_idx) { return conn_input_cache[p_idx].color; } -Vector2 GraphNode::get_connection_output_pos(int p_idx) { +Vector2 GraphNode::get_connection_output_position(int p_idx) { if (connpos_dirty) _connpos_update(); @@ -687,10 +690,10 @@ void GraphNode::_bind_methods() { ClassDB::bind_method(D_METHOD("get_connection_output_count"), &GraphNode::get_connection_output_count); ClassDB::bind_method(D_METHOD("get_connection_input_count"), &GraphNode::get_connection_input_count); - ClassDB::bind_method(D_METHOD("get_connection_output_pos", "idx"), &GraphNode::get_connection_output_pos); + ClassDB::bind_method(D_METHOD("get_connection_output_position", "idx"), &GraphNode::get_connection_output_position); ClassDB::bind_method(D_METHOD("get_connection_output_type", "idx"), &GraphNode::get_connection_output_type); ClassDB::bind_method(D_METHOD("get_connection_output_color", "idx"), &GraphNode::get_connection_output_color); - ClassDB::bind_method(D_METHOD("get_connection_input_pos", "idx"), &GraphNode::get_connection_input_pos); + ClassDB::bind_method(D_METHOD("get_connection_input_position", "idx"), &GraphNode::get_connection_input_position); ClassDB::bind_method(D_METHOD("get_connection_input_type", "idx"), &GraphNode::get_connection_input_type); ClassDB::bind_method(D_METHOD("get_connection_input_color", "idx"), &GraphNode::get_connection_input_color); diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index a606e47acd..a0840544dd 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -138,10 +138,10 @@ public: int get_connection_input_count(); int get_connection_output_count(); - Vector2 get_connection_input_pos(int p_idx); + Vector2 get_connection_input_position(int p_idx); int get_connection_input_type(int p_idx); Color get_connection_input_color(int p_idx); - Vector2 get_connection_output_pos(int p_idx); + Vector2 get_connection_output_position(int p_idx); int get_connection_output_type(int p_idx); Color get_connection_output_color(int p_idx); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 9a605c98f3..74cc09d0a6 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1117,7 +1117,7 @@ void ItemList::_scroll_changed(double) { update(); } -int ItemList::get_item_at_pos(const Point2 &p_pos, bool p_exact) const { +int ItemList::get_item_at_position(const Point2 &p_pos, bool p_exact) const { Vector2 pos = p_pos; Ref<StyleBox> bg = get_stylebox("bg"); @@ -1165,7 +1165,7 @@ bool ItemList::is_pos_at_end_of_items(const Point2 &p_pos) const { String ItemList::get_tooltip(const Point2 &p_pos) const { - int closest = get_item_at_pos(p_pos); + int closest = get_item_at_position(p_pos); if (closest != -1) { if (!items[closest].tooltip_enabled) { @@ -1362,7 +1362,7 @@ void ItemList::_bind_methods() { ClassDB::bind_method(D_METHOD("set_auto_height", "enable"), &ItemList::set_auto_height); ClassDB::bind_method(D_METHOD("has_auto_height"), &ItemList::has_auto_height); - ClassDB::bind_method(D_METHOD("get_item_at_pos", "pos", "exact"), &ItemList::get_item_at_pos, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("get_item_at_position", "position", "exact"), &ItemList::get_item_at_position, DEFVAL(false)); ClassDB::bind_method(D_METHOD("ensure_current_is_visible"), &ItemList::ensure_current_is_visible); @@ -1395,7 +1395,7 @@ void ItemList::_bind_methods() { BIND_ENUM_CONSTANT(SELECT_MULTI); ADD_SIGNAL(MethodInfo("item_selected", PropertyInfo(Variant::INT, "index"))); - ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::VECTOR2, "atpos"))); + ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::VECTOR2, "at_position"))); ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "selected"))); ADD_SIGNAL(MethodInfo("item_activated", PropertyInfo(Variant::INT, "index"))); diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index 673b7d8956..ccdd705325 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -199,7 +199,7 @@ public: int find_metadata(const Variant &p_metadata) const; virtual String get_tooltip(const Point2 &p_pos) const; - int get_item_at_pos(const Point2 &p_pos, bool p_exact = false) const; + int get_item_at_position(const Point2 &p_pos, bool p_exact = false) const; bool is_pos_at_end_of_items(const Point2 &p_pos) const; void set_icon_scale(real_t p_scale); diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 6a5f56c78c..7493ea95a8 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -49,7 +49,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { if (b.is_valid()) { if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT) { - menu->set_position(get_global_transform().xform(get_local_mouse_pos())); + menu->set_position(get_global_transform().xform(get_local_mouse_position())); menu->set_size(Vector2(1, 1)); menu->popup(); grab_focus(); @@ -186,7 +186,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { cached_width += font->get_char_size(text[i]).width; } - set_cursor_pos(0); + set_cursor_position(0); _text_changed(); } @@ -273,7 +273,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { delete_text(cc, cursor_pos); - set_cursor_pos(cc); + set_cursor_position(cc); } else { undo_text = text; @@ -297,7 +297,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { #ifdef APPLE_STYLE_KEYS if (k->get_command()) { - set_cursor_pos(0); + set_cursor_position(0); } else if (k->get_alt()) { #else @@ -319,10 +319,10 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { cc--; } - set_cursor_pos(cc); + set_cursor_position(cc); } else { - set_cursor_pos(get_cursor_pos() - 1); + set_cursor_position(get_cursor_position() - 1); } shift_selection_check_post(k->get_shift()); @@ -341,7 +341,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { #ifdef APPLE_STYLE_KEYS if (k->get_command()) { - set_cursor_pos(text.length()); + set_cursor_position(text.length()); } else if (k->get_alt()) { #else if (k->get_alt()) { @@ -362,10 +362,10 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { cc++; } - set_cursor_pos(cc); + set_cursor_position(cc); } else { - set_cursor_pos(get_cursor_pos() + 1); + set_cursor_position(get_cursor_position() + 1); } shift_selection_check_post(k->get_shift()); @@ -418,7 +418,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { } else { undo_text = text; - set_cursor_pos(cursor_pos + 1); + set_cursor_position(cursor_pos + 1); delete_char(); } @@ -433,7 +433,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { case KEY_HOME: { shift_selection_check_pre(k->get_shift()); - set_cursor_pos(0); + set_cursor_position(0); shift_selection_check_post(k->get_shift()); } break; case KEY_KP_1: { @@ -446,7 +446,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { case KEY_END: { shift_selection_check_pre(k->get_shift()); - set_cursor_pos(text.length()); + set_cursor_position(text.length()); shift_selection_check_post(k->get_shift()); } break; @@ -546,7 +546,7 @@ void LineEdit::_notification(int p_what) { #endif case NOTIFICATION_RESIZED: { - set_cursor_pos(get_cursor_pos()); + set_cursor_position(get_cursor_position()); } break; case MainLoop::NOTIFICATION_WM_FOCUS_IN: { @@ -742,7 +742,7 @@ void LineEdit::_notification(int p_what) { draw_caret = true; } - Point2 cursor_pos = Point2(get_cursor_pos(), 1) * get_minimum_size().height; + Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height; OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos); OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this); @@ -806,9 +806,9 @@ void LineEdit::undo() { cached_width += font->get_char_size(text[i]).width; if (old_cursor_pos > text.length()) { - set_cursor_pos(text.length()); + set_cursor_position(text.length()); } else { - set_cursor_pos(old_cursor_pos); + set_cursor_position(old_cursor_pos); } _text_changed(); @@ -869,14 +869,14 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { ofs++; } - set_cursor_pos(ofs); + set_cursor_position(ofs); /* int new_cursor_pos=p_x; int charwidth=draw_area->get_font_char_width(' ',0); new_cursor_pos=( ( (new_cursor_pos-2)+ (charwidth/2) ) /charwidth ); if (new_cursor_pos>(int)text.length()) new_cursor_pos=text.length(); - set_cursor_pos(window_pos+new_cursor_pos); */ + set_cursor_position(window_pos+new_cursor_pos); */ } bool LineEdit::cursor_get_blink_enabled() const { @@ -929,7 +929,7 @@ void LineEdit::delete_char() { text.erase(cursor_pos - 1, 1); - set_cursor_pos(get_cursor_pos() - 1); + set_cursor_position(get_cursor_position() - 1); if (cursor_pos == window_pos) { @@ -1011,7 +1011,7 @@ float LineEdit::get_placeholder_alpha() const { return placeholder_alpha; } -void LineEdit::set_cursor_pos(int p_pos) { +void LineEdit::set_cursor_position(int p_pos) { if (p_pos > (int)text.length()) p_pos = text.length(); @@ -1065,7 +1065,7 @@ void LineEdit::set_cursor_pos(int p_pos) { update(); } -int LineEdit::get_cursor_pos() const { +int LineEdit::get_cursor_position() const { return cursor_pos; } @@ -1093,7 +1093,7 @@ void LineEdit::append_at_cursor(String p_text) { String pre = text.substr(0, cursor_pos); String post = text.substr(cursor_pos, text.length() - cursor_pos); text = pre + p_text + post; - set_cursor_pos(cursor_pos + p_text.length()); + set_cursor_position(cursor_pos + p_text.length()); } } @@ -1330,8 +1330,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("get_placeholder"), &LineEdit::get_placeholder); ClassDB::bind_method(D_METHOD("set_placeholder_alpha", "alpha"), &LineEdit::set_placeholder_alpha); ClassDB::bind_method(D_METHOD("get_placeholder_alpha"), &LineEdit::get_placeholder_alpha); - ClassDB::bind_method(D_METHOD("set_cursor_pos", "pos"), &LineEdit::set_cursor_pos); - ClassDB::bind_method(D_METHOD("get_cursor_pos"), &LineEdit::get_cursor_pos); + ClassDB::bind_method(D_METHOD("set_cursor_position", "position"), &LineEdit::set_cursor_position); + ClassDB::bind_method(D_METHOD("get_cursor_position"), &LineEdit::get_cursor_position); ClassDB::bind_method(D_METHOD("set_expand_to_text_length", "enabled"), &LineEdit::set_expand_to_text_length); ClassDB::bind_method(D_METHOD("get_expand_to_text_length"), &LineEdit::get_expand_to_text_length); ClassDB::bind_method(D_METHOD("cursor_set_blink_enabled", "enabled"), &LineEdit::cursor_set_blink_enabled); diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 52a4a29a33..661f9b60b9 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -149,8 +149,8 @@ public: String get_placeholder() const; void set_placeholder_alpha(float p_alpha); float get_placeholder_alpha() const; - void set_cursor_pos(int p_pos); - int get_cursor_pos() const; + void set_cursor_position(int p_pos); + int get_cursor_position() const; void set_max_length(int p_max_length); int get_max_length() const; void append_at_cursor(String p_text); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 71b9c4ec72..d9287e6f63 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -84,7 +84,7 @@ Rect2 RichTextLabel::_get_text_rect() { Ref<StyleBox> style = get_stylebox("normal"); return Rect2(style->get_offset(), get_size() - style->get_minimum_size()); } -void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos, Item **r_click_item, int *r_click_char, bool *r_outside, int p_char_count) { +int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos, Item **r_click_item, int *r_click_char, bool *r_outside, int p_char_count) { RID ci; if (r_outside) @@ -104,9 +104,11 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int int line = 0; int spaces = 0; + int height = get_size().y; + if (p_mode != PROCESS_CACHE) { - ERR_FAIL_INDEX(line, l.offset_caches.size()); + ERR_FAIL_INDEX_V(line, l.offset_caches.size(), 0); line_ofs = l.offset_caches[line]; } @@ -133,12 +135,20 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int //line height should be the font height for the first time, this ensures that an empty line will never have zero height and successive newlines are displayed int line_height = cfont->get_height(); + int nonblank_line_count = 0; //number of nonblank lines as counted during PROCESS_DRAW + Variant meta; +#define RETURN return nonblank_line_count + #define NEW_LINE \ { \ if (p_mode != PROCESS_CACHE) { \ line++; \ + if (!line_is_blank) { \ + nonblank_line_count++; \ + } \ + line_is_blank = true; \ if (line < l.offset_caches.size()) \ line_ofs = l.offset_caches[line]; \ wofs = margin; \ @@ -168,7 +178,7 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int if (r_outside) *r_outside = true; \ *r_click_item = it; \ *r_click_char = rchar; \ - return; \ + RETURN; \ } \ } @@ -185,7 +195,7 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int if (r_outside) *r_outside = true; \ *r_click_item = it; \ *r_click_char = rchar; \ - return; \ + RETURN; \ } \ NEW_LINE \ } @@ -196,7 +206,7 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int if (r_outside) *r_outside = false; \ *r_click_item = it; \ *r_click_char = rchar; \ - return; \ + RETURN; \ } \ wofs += m_width; \ } @@ -206,6 +216,9 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int line_height = m_height; \ } +#define YRANGE_VISIBLE(m_top, m_height) \ + (m_height > 0 && ((m_top >= 0 && m_top < height) || ((m_top + m_height - 1) >= 0 && (m_top + m_height - 1) < height))) + Color selection_fg; Color selection_bg; @@ -214,8 +227,10 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int selection_fg = get_color("font_color_selected"); selection_bg = get_color("selection_color"); } + int rchar = 0; int lh = 0; + bool line_is_blank = true; while (it) { @@ -327,7 +342,10 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int int cw = 0; - bool visible = visible_characters < 0 || p_char_count < visible_characters; + bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - (fh - 0 * ascent), fh); //getting rid of ascent seems to work?? + if (visible) + line_is_blank = false; + if (c[i] == '\t') visible = false; @@ -384,7 +402,9 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int ENSURE_WIDTH(img->image->get_width()); - bool visible = visible_characters < 0 || p_char_count < visible_characters; + bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->image->get_height(), img->image->get_height()); + if (visible) + line_is_blank = false; if (p_mode == PROCESS_DRAW && visible) { img->image->draw(ci, p_ofs + Point2(align_ofs + wofs, y + lh - font->get_descent() - img->image->get_height())); @@ -398,8 +418,10 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int case ITEM_NEWLINE: { lh = 0; - if (p_mode != PROCESS_CACHE) + if (p_mode != PROCESS_CACHE) { lh = line < l.height_caches.size() ? l.height_caches[line] : 1; + line_is_blank = true; + } } break; case ITEM_TABLE: { @@ -436,7 +458,7 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int idx++; } - //compute available width and total radio (for expanders) + //compute available width and total ratio (for expanders) int total_ratio = 0; int available_width = p_width - hseparation * (table->columns.size() - 1); @@ -494,12 +516,14 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int int lines_ofs = p_ofs.y + offset.y + draw_ofs.y; bool visible = lines_ofs < get_size().height && lines_ofs + lines_h >= 0; + if (visible) + line_is_blank = false; for (int i = 0; i < frame->lines.size(); i++) { if (visible) { if (p_mode == PROCESS_DRAW) { - _process_line(frame, p_ofs + offset + draw_ofs + Vector2(0, yofs), ly, table->columns[column].width, i, PROCESS_DRAW, cfont, ccolor); + nonblank_line_count += _process_line(frame, p_ofs + offset + draw_ofs + Vector2(0, yofs), ly, table->columns[column].width, i, PROCESS_DRAW, cfont, ccolor); } else if (p_mode == PROCESS_POINTER) { _process_line(frame, p_ofs + offset + draw_ofs + Vector2(0, yofs), ly, table->columns[column].width, i, PROCESS_POINTER, cfont, ccolor, p_click_pos, r_click_item, r_click_char, r_outside); } @@ -547,15 +571,17 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int if (r_outside) *r_outside = true; *r_click_item = itp; *r_click_char = rchar; - return; + RETURN; } break; } } - NEW_LINE; + RETURN; + +#undef RETURN #undef NEW_LINE #undef ENSURE_WIDTH #undef ADVANCE @@ -665,14 +691,14 @@ void RichTextLabel::_notification(int p_what) { if (from_line >= main->lines.size()) break; //nothing to draw - int y = (main->lines[from_line].height_accum_cache - main->lines[from_line].height_cache) - ofs; Ref<Font> base_font = get_font("normal_font"); Color base_color = get_color("default_color"); + visible_line_count = 0; while (y < size.height && from_line < main->lines.size()) { - _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, Point2i(), NULL, NULL, NULL, total_chars); + visible_line_count += _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, Point2i(), NULL, NULL, NULL, total_chars); total_chars += main->lines[from_line].char_count; from_line++; } @@ -1013,7 +1039,7 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) { if (p_frame->first_invalid_line == p_frame->lines.size()) return; - //validate invalid lines!s + //validate invalid lines Size2 size = get_size(); Rect2 text_rect = _get_text_rect(); @@ -1665,6 +1691,12 @@ int RichTextLabel::get_line_count() const { return current_frame->lines.size(); } +int RichTextLabel::get_visible_line_count() const { + if (!is_visible()) + return 0; + return visible_line_count; +} + void RichTextLabel::set_selection_enabled(bool p_enabled) { selection.enabled = p_enabled; @@ -1907,6 +1939,9 @@ void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_bbcode", "enable"), &RichTextLabel::set_use_bbcode); ClassDB::bind_method(D_METHOD("is_using_bbcode"), &RichTextLabel::is_using_bbcode); + ClassDB::bind_method(D_METHOD("get_line_count"), &RichTextLabel::get_line_count); + ClassDB::bind_method(D_METHOD("get_visible_line_count"), &RichTextLabel::get_visible_line_count); + ADD_GROUP("BBCode", "bbcode_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bbcode_enabled"), "set_use_bbcode", "is_using_bbcode"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "bbcode_text", PROPERTY_HINT_MULTILINE_TEXT), "set_bbcode", "get_bbcode"); @@ -1995,6 +2030,7 @@ RichTextLabel::RichTextLabel() { visible_characters = -1; percent_visible = 1; + visible_line_count = 0; set_clip_contents(true); } diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 4db2c3a8e9..24c1e5eb59 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -217,6 +217,7 @@ private: int scroll_w; bool updating_scroll; int current_idx; + int visible_line_count; int tab_size; bool underline_meta; @@ -260,7 +261,7 @@ private: int visible_characters; float percent_visible; - void _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0); + int _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0); void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL); Ref<Font> _find_font(Item *p_item); @@ -325,6 +326,7 @@ public: void scroll_to_line(int p_line); int get_line_count() const; + int get_visible_line_count() const; VScrollBar *get_v_scroll() { return vscroll; } diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 16d1b320b7..41f4beb1c9 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -106,9 +106,9 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { if (ofs < grabber_ofs) { if (scrolling) { - target_scroll = target_scroll - get_page(); + target_scroll = CLAMP(target_scroll - get_page(), get_min(), get_max() - get_page()); } else { - target_scroll = get_value() - get_page(); + target_scroll = CLAMP(get_value() - get_page(), get_min(), get_max() - get_page()); } if (smooth_scroll_enabled) { @@ -130,9 +130,9 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { update(); } else { if (scrolling) { - target_scroll = target_scroll + get_page(); + target_scroll = CLAMP(target_scroll + get_page(), get_min(), get_max() - get_page()); } else { - target_scroll = get_value() + get_page(); + target_scroll = CLAMP(get_value() + get_page(), get_min(), get_max() - get_page()); } if (smooth_scroll_enabled) { diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index e182e491d3..c71093b947 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -182,7 +182,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { } } -void ScrollContainer::_update_scrollbar_pos() { +void ScrollContainer::_update_scrollbar_position() { Size2 hmin = h_scroll->get_combined_minimum_size(); Size2 vmin = v_scroll->get_combined_minimum_size(); @@ -205,7 +205,7 @@ void ScrollContainer::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - call_deferred("_update_scrollbar_pos"); + call_deferred("_update_scrollbar_position"); }; if (p_what == NOTIFICATION_SORT_CHILDREN) { @@ -448,7 +448,7 @@ void ScrollContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"), &ScrollContainer::is_h_scroll_enabled); ClassDB::bind_method(D_METHOD("set_enable_v_scroll", "enable"), &ScrollContainer::set_enable_v_scroll); ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &ScrollContainer::is_v_scroll_enabled); - ClassDB::bind_method(D_METHOD("_update_scrollbar_pos"), &ScrollContainer::_update_scrollbar_pos); + ClassDB::bind_method(D_METHOD("_update_scrollbar_position"), &ScrollContainer::_update_scrollbar_position); ClassDB::bind_method(D_METHOD("set_h_scroll", "val"), &ScrollContainer::set_h_scroll); ClassDB::bind_method(D_METHOD("get_h_scroll"), &ScrollContainer::get_h_scroll); ClassDB::bind_method(D_METHOD("set_v_scroll", "val"), &ScrollContainer::set_v_scroll); diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h index 9076be0d72..2c5d60de6c 100644 --- a/scene/gui/scroll_container.h +++ b/scene/gui/scroll_container.h @@ -70,7 +70,7 @@ protected: void _scroll_moved(float); static void _bind_methods(); - void _update_scrollbar_pos(); + void _update_scrollbar_position(); public: int get_v_scroll() const; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index f462989f53..60b6746ae8 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -72,7 +72,7 @@ void SpinBox::_range_click_timeout() { if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { - bool up = get_local_mouse_pos().y < (get_size().height / 2); + bool up = get_local_mouse_position().y < (get_size().height / 2); set_value(get_value() + (up ? get_step() : -get_step())); if (range_click_timer->is_one_shot()) { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index db6d257640..d79ce25344 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1773,7 +1773,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (mb->get_button_index() == BUTTON_RIGHT && context_menu_enabled) { - menu->set_position(get_global_transform().xform(get_local_mouse_pos())); + menu->set_position(get_global_transform().xform(get_local_mouse_position())); menu->set_size(Vector2(1, 1)); menu->popup(); grab_focus(); @@ -1844,7 +1844,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (k->is_pressed()) { - highlighted_word = get_word_at_pos(get_local_mouse_pos()); + highlighted_word = get_word_at_pos(get_local_mouse_position()); update(); } else { @@ -2804,8 +2804,12 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { _remove_text(i, 0, i, 1); } } else { - if (get_line(cursor.line).begins_with("#")) + if (get_line(cursor.line).begins_with("#")) { _remove_text(cursor.line, 0, cursor.line, 1); + if (cursor.column >= get_line(cursor.line).length()) { + cursor.column = MAX(0, get_line(cursor.line).length() - 1); + } + } } update(); } @@ -3495,7 +3499,7 @@ String TextEdit::get_text() { String TextEdit::get_text_for_lookup_completion() { int row, col; - _get_mouse_pos(get_local_mouse_pos(), row, col); + _get_mouse_pos(get_local_mouse_position(), row, col); String longthing; int len = text.size(); @@ -4262,6 +4266,10 @@ bool TextEdit::is_insert_mode() const { return insert_mode; } +bool TextEdit::is_insert_text_operation() { + return (current_op.type == TextOperation::TYPE_INSERT); +} + uint32_t TextEdit::get_version() const { return current_op.version; } diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 68ef559f46..7e61c4e8b1 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -386,6 +386,8 @@ public: void begin_complex_operation(); void end_complex_operation(); + bool is_insert_text_operation(); + void set_text(String p_text); void insert_text_at_cursor(const String &p_text); void insert_at(const String &p_text, int at); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 7fa29d312e..8d6eb0f8e2 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1528,7 +1528,7 @@ void Tree::_range_click_timeout() { if (range_item_last && !range_drag_enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { - Point2 pos = get_local_mouse_pos() - cache.bg->get_offset(); + Point2 pos = get_local_mouse_position() - cache.bg->get_offset(); if (show_column_titles) { pos.y -= _get_title_button_height(); @@ -1676,7 +1676,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_item->select(col); emit_signal("multi_selected", p_item, col, true); if (p_button == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", get_local_mouse_pos()); + emit_signal("item_rmb_selected", get_local_mouse_position()); } //p_item->selected_signal.call(col); @@ -1697,7 +1697,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool select_single_item(p_item, root, col, selected_item, &inrange); if (p_button == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", get_local_mouse_pos()); + emit_signal("item_rmb_selected", get_local_mouse_position()); } } else { @@ -1713,7 +1713,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool } if (p_button == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", get_local_mouse_pos()); + emit_signal("item_rmb_selected", get_local_mouse_position()); } } } @@ -1914,7 +1914,7 @@ void Tree::_text_editor_modal_close() { return; } - if (value_editor->has_point(value_editor->get_local_mouse_pos())) + if (value_editor->has_point(value_editor->get_local_mouse_position())) return; text_editor_enter(text_editor->get_text()); @@ -2010,7 +2010,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (!k->is_pressed()) return; - if (k->get_alt() || k->get_command() || (k->get_shift() && k->get_unicode() == 0) || k->get_metakey()) + if (k->get_command() || (k->get_shift() && k->get_unicode() == 0) || k->get_metakey()) return; if (!root) return; @@ -2025,48 +2025,47 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { break; \ } case KEY_RIGHT: { + bool dobreak = true; //TreeItem *next = NULL; if (!selected_item) break; - if (select_mode == SELECT_ROW) + if (select_mode == SELECT_ROW) { EXIT_BREAK; - if (selected_col >= (columns.size() - 1)) + } + if (selected_col > (columns.size() - 1)) { EXIT_BREAK; - if (select_mode == SELECT_MULTI) { - selected_col++; - emit_signal("cell_selected"); + } + if (k->get_alt()) { + selected_item->set_collapsed(false); + TreeItem *next = selected_item->get_children(); + while (next && next != selected_item->next) { + next->set_collapsed(false); + next = next->get_next_visible(); + } + } else if (selected_col == (columns.size() - 1)) { + if (selected_item->get_children() != NULL && selected_item->is_collapsed()) { + selected_item->set_collapsed(false); + } else { + selected_col = 0; + dobreak = false; // fall through to key_down + } } else { + if (select_mode == SELECT_MULTI) { + selected_col++; + emit_signal("cell_selected"); + } else { - selected_item->select(selected_col + 1); + selected_item->select(selected_col + 1); + } } - update(); ensure_cursor_is_visible(); accept_event(); - - } break; - case KEY_LEFT: { - - //TreeItem *next = NULL; - if (!selected_item) + if (dobreak) { break; - if (select_mode == SELECT_ROW) - EXIT_BREAK; - if (selected_col <= 0) - EXIT_BREAK; - if (select_mode == SELECT_MULTI) { - selected_col--; - emit_signal("cell_selected"); - } else { - - selected_item->select(selected_col - 1); } - - update(); - accept_event(); - - } break; + } case KEY_DOWN: { TreeItem *next = NULL; @@ -2113,6 +2112,48 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { accept_event(); } break; + case KEY_LEFT: { + bool dobreak = true; + + //TreeItem *next = NULL; + if (!selected_item) + break; + if (select_mode == SELECT_ROW) { + EXIT_BREAK; + } + if (selected_col < 0) { + EXIT_BREAK; + } + if (k->get_alt()) { + selected_item->set_collapsed(true); + TreeItem *next = selected_item->get_children(); + while (next && next != selected_item->next) { + next->set_collapsed(true); + next = next->get_next_visible(); + } + } else if (selected_col == 0) { + if (selected_item->get_children() != NULL && !selected_item->is_collapsed()) { + selected_item->set_collapsed(true); + } else { + selected_col = columns.size() - 1; + dobreak = false; // fall through to key_up + } + } else { + if (select_mode == SELECT_MULTI) { + selected_col--; + emit_signal("cell_selected"); + } else { + + selected_item->select(selected_col - 1); + } + } + update(); + accept_event(); + + if (dobreak) { + break; + } + } case KEY_UP: { TreeItem *prev = NULL; @@ -2429,7 +2470,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (cache.click_type == Cache::CLICK_BUTTON) { // make sure in case of wrong reference after reconstructing whole TreeItems - cache.click_item = get_item_at_pos(cache.click_pos); + cache.click_item = get_item_at_position(cache.click_pos); emit_signal("button_pressed", cache.click_item, cache.click_column, cache.click_id); } cache.click_type = Cache::CLICK_NONE; @@ -2489,7 +2530,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } if (!root || (!root->get_children() && hide_root)) { if (b->get_button_index() == BUTTON_RIGHT && allow_rmb_select) { - emit_signal("empty_tree_rmb_selected", get_local_mouse_pos()); + emit_signal("empty_tree_rmb_selected", get_local_mouse_position()); } break; } @@ -3387,7 +3428,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ return NULL; } -int Tree::get_column_at_pos(const Point2 &p_pos) const { +int Tree::get_column_at_position(const Point2 &p_pos) const { if (root) { @@ -3413,7 +3454,7 @@ int Tree::get_column_at_pos(const Point2 &p_pos) const { return -1; } -int Tree::get_drop_section_at_pos(const Point2 &p_pos) const { +int Tree::get_drop_section_at_position(const Point2 &p_pos) const { if (root) { @@ -3438,7 +3479,7 @@ int Tree::get_drop_section_at_pos(const Point2 &p_pos) const { return -100; } -TreeItem *Tree::get_item_at_pos(const Point2 &p_pos) const { +TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const { if (root) { @@ -3611,9 +3652,9 @@ void Tree::_bind_methods() { ClassDB::bind_method(D_METHOD("get_edited_column"), &Tree::get_edited_column); ClassDB::bind_method(D_METHOD("get_custom_popup_rect"), &Tree::get_custom_popup_rect); ClassDB::bind_method(D_METHOD("get_item_area_rect", "item", "column"), &Tree::_get_item_rect, DEFVAL(-1)); - ClassDB::bind_method(D_METHOD("get_item_at_pos", "pos"), &Tree::get_item_at_pos); - ClassDB::bind_method(D_METHOD("get_column_at_pos", "pos"), &Tree::get_column_at_pos); - ClassDB::bind_method(D_METHOD("get_drop_section_at_pos", "pos"), &Tree::get_drop_section_at_pos); + ClassDB::bind_method(D_METHOD("get_item_at_position", "position"), &Tree::get_item_at_position); + ClassDB::bind_method(D_METHOD("get_column_at_position", "position"), &Tree::get_column_at_position); + ClassDB::bind_method(D_METHOD("get_drop_section_at_position", "position"), &Tree::get_drop_section_at_position); ClassDB::bind_method(D_METHOD("ensure_cursor_is_visible"), &Tree::ensure_cursor_is_visible); @@ -3639,8 +3680,8 @@ void Tree::_bind_methods() { ADD_SIGNAL(MethodInfo("item_selected")); ADD_SIGNAL(MethodInfo("cell_selected")); ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::OBJECT, "item"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::BOOL, "selected"))); - ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos"))); - ADD_SIGNAL(MethodInfo("empty_tree_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos"))); + ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::VECTOR2, "position"))); + ADD_SIGNAL(MethodInfo("empty_tree_rmb_selected", PropertyInfo(Variant::VECTOR2, "position"))); ADD_SIGNAL(MethodInfo("item_edited")); ADD_SIGNAL(MethodInfo("item_rmb_edited")); ADD_SIGNAL(MethodInfo("item_custom_button_pressed")); diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 5f19558597..e723fa227b 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -525,9 +525,9 @@ protected: public: virtual String get_tooltip(const Point2 &p_pos) const; - TreeItem *get_item_at_pos(const Point2 &p_pos) const; - int get_column_at_pos(const Point2 &p_pos) const; - int get_drop_section_at_pos(const Point2 &p_pos) const; + TreeItem *get_item_at_position(const Point2 &p_pos) const; + int get_column_at_position(const Point2 &p_pos) const; + int get_drop_section_at_position(const Point2 &p_pos) const; void clear(); diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index a92155cc4f..816556af30 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -278,11 +278,11 @@ String VideoPlayer::get_stream_name() const { return stream->get_name(); }; -float VideoPlayer::get_stream_pos() const { +float VideoPlayer::get_stream_position() const { if (playback.is_null()) return 0; - return playback->get_pos(); + return playback->get_playback_position(); }; Ref<Texture> VideoPlayer::get_video_texture() { @@ -327,7 +327,7 @@ void VideoPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_stream_name"), &VideoPlayer::get_stream_name); - ClassDB::bind_method(D_METHOD("get_stream_pos"), &VideoPlayer::get_stream_pos); + ClassDB::bind_method(D_METHOD("get_stream_position"), &VideoPlayer::get_stream_position); ClassDB::bind_method(D_METHOD("set_autoplay", "enabled"), &VideoPlayer::set_autoplay); ClassDB::bind_method(D_METHOD("has_autoplay"), &VideoPlayer::has_autoplay); diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index b78f3aabe7..bea10907bb 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -92,7 +92,7 @@ public: float get_volume_db() const; String get_stream_name() const; - float get_stream_pos() const; + float get_stream_position() const; void set_autoplay(bool p_enable); bool has_autoplay() const; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index a30fc03aa9..658701dcc7 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "node.h" +#include "core/core_string_names.h" #include "instance_placeholder.h" #include "io/resource_loader.h" #include "message_queue.h" @@ -2104,12 +2105,22 @@ Node *Node::_duplicate(int p_flags) const { get_property_list(&plist); + StringName script_property_name = CoreStringNames::get_singleton()->_script; + + if (p_flags & DUPLICATE_SCRIPTS) { + bool is_valid = false; + Variant script = get(script_property_name, &is_valid); + if (is_valid) { + node->set(script_property_name, script); + } + } + for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) continue; String name = E->get().name; - if (!(p_flags & DUPLICATE_SCRIPTS) && name == "script/script") + if (name == script_property_name) continue; Variant value = get(name); @@ -2572,8 +2583,11 @@ void Node::print_stray_nodes() { void Node::queue_delete() { - ERR_FAIL_COND(!is_inside_tree()); - get_tree()->queue_delete(this); + if (is_inside_tree()) { + get_tree()->queue_delete(this); + } else { + SceneTree::get_singleton()->queue_delete(this); + } } Array Node::_get_children() const { @@ -2693,7 +2707,7 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("add_to_group", "group", "persistent"), &Node::add_to_group, DEFVAL(false)); ClassDB::bind_method(D_METHOD("remove_from_group", "group"), &Node::remove_from_group); ClassDB::bind_method(D_METHOD("is_in_group", "group"), &Node::is_in_group); - ClassDB::bind_method(D_METHOD("move_child", "child_node", "to_pos"), &Node::move_child); + ClassDB::bind_method(D_METHOD("move_child", "child_node", "to_position"), &Node::move_child); ClassDB::bind_method(D_METHOD("get_groups"), &Node::_get_groups); ClassDB::bind_method(D_METHOD("raise"), &Node::raise); ClassDB::bind_method(D_METHOD("set_owner", "owner"), &Node::set_owner); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index d27a1a5641..e19f2031dd 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1339,7 +1339,7 @@ Vector2 Viewport::get_mouse_position() const { void Viewport::warp_mouse(const Vector2 &p_pos) { Vector2 gpos = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse().xform(p_pos); - Input::get_singleton()->warp_mouse_pos(gpos); + Input::get_singleton()->warp_mouse_position(gpos); } void Viewport::_gui_sort_subwindows() { @@ -2673,7 +2673,7 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_attach_to_screen_rect", "rect"), &Viewport::set_attach_to_screen_rect); ClassDB::bind_method(D_METHOD("get_mouse_position"), &Viewport::get_mouse_position); - ClassDB::bind_method(D_METHOD("warp_mouse", "to_pos"), &Viewport::warp_mouse); + ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Viewport::warp_mouse); ClassDB::bind_method(D_METHOD("gui_has_modal_stack"), &Viewport::gui_has_modal_stack); ClassDB::bind_method(D_METHOD("gui_get_drag_data"), &Viewport::gui_get_drag_data); diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index eae95d9247..8dcc8d4e14 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -613,7 +613,7 @@ int Animation::transform_track_insert_key(int p_track, float p_time, const Vecto return ret; } -void Animation::track_remove_key_at_pos(int p_track, float p_pos) { +void Animation::track_remove_key_at_position(int p_track, float p_pos) { int idx = track_find_key(p_track, p_pos, true); ERR_FAIL_COND(idx < 0); @@ -707,12 +707,12 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key Dictionary d = p_key; Vector3 loc; - if (d.has("loc")) - loc = d["loc"]; + if (d.has("location")) + loc = d["location"]; Quat rot; - if (d.has("rot")) - rot = d["rot"]; + if (d.has("rotation")) + rot = d["rotation"]; Vector3 scale; if (d.has("scale")) @@ -799,8 +799,8 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const { ERR_FAIL_INDEX_V(p_key_idx, tt->transforms.size(), Variant()); Dictionary d; - d["loc"] = tt->transforms[p_key_idx].value.loc; - d["rot"] = tt->transforms[p_key_idx].value.rot; + d["location"] = tt->transforms[p_key_idx].value.loc; + d["rotation"] = tt->transforms[p_key_idx].value.rot; d["scale"] = tt->transforms[p_key_idx].value.scale; return d; @@ -903,10 +903,10 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p TransformTrack *tt = static_cast<TransformTrack *>(t); ERR_FAIL_INDEX(p_key_idx, tt->transforms.size()); Dictionary d = p_value; - if (d.has("loc")) - tt->transforms[p_key_idx].value.loc = d["loc"]; - if (d.has("rot")) - tt->transforms[p_key_idx].value.rot = d["rot"]; + if (d.has("location")) + tt->transforms[p_key_idx].value.loc = d["location"]; + if (d.has("rotation")) + tt->transforms[p_key_idx].value.rot = d["rotation"]; if (d.has("scale")) tt->transforms[p_key_idx].value.scale = d["scale"]; @@ -1590,7 +1590,7 @@ float Animation::get_step() const { void Animation::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_track", "type", "at_pos"), &Animation::add_track, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("add_track", "type", "at_position"), &Animation::add_track, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("remove_track", "idx"), &Animation::remove_track); ClassDB::bind_method(D_METHOD("get_track_count"), &Animation::get_track_count); ClassDB::bind_method(D_METHOD("track_get_type", "idx"), &Animation::track_get_type); @@ -1604,10 +1604,10 @@ void Animation::_bind_methods() { ClassDB::bind_method(D_METHOD("track_set_imported", "idx", "imported"), &Animation::track_set_imported); ClassDB::bind_method(D_METHOD("track_is_imported", "idx"), &Animation::track_is_imported); - ClassDB::bind_method(D_METHOD("transform_track_insert_key", "idx", "time", "loc", "rot", "scale"), &Animation::transform_track_insert_key); + ClassDB::bind_method(D_METHOD("transform_track_insert_key", "idx", "time", "location", "rotation", "scale"), &Animation::transform_track_insert_key); ClassDB::bind_method(D_METHOD("track_insert_key", "idx", "time", "key", "transition"), &Animation::track_insert_key, DEFVAL(1)); ClassDB::bind_method(D_METHOD("track_remove_key", "idx", "key_idx"), &Animation::track_remove_key); - ClassDB::bind_method(D_METHOD("track_remove_key_at_pos", "idx", "pos"), &Animation::track_remove_key_at_pos); + ClassDB::bind_method(D_METHOD("track_remove_key_at_position", "idx", "position"), &Animation::track_remove_key_at_position); ClassDB::bind_method(D_METHOD("track_set_key_value", "idx", "key", "value"), &Animation::track_set_key_value); ClassDB::bind_method(D_METHOD("track_set_key_transition", "idx", "key_idx", "transition"), &Animation::track_set_key_transition); ClassDB::bind_method(D_METHOD("track_get_key_transition", "idx", "key_idx"), &Animation::track_get_key_transition); diff --git a/scene/resources/animation.h b/scene/resources/animation.h index e653f6b124..6235e161a3 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -245,7 +245,7 @@ public: void track_set_key_value(int p_track, int p_key_idx, const Variant &p_value); int track_find_key(int p_track, float p_time, bool p_exact = false) const; void track_remove_key(int p_track, int p_idx); - void track_remove_key_at_pos(int p_track, float p_pos); + void track_remove_key_at_position(int p_track, float p_pos); int track_get_key_count(int p_track) const; Variant track_get_key_value(int p_track, int p_key_idx) const; float track_get_key_time(int p_track, int p_key_idx) const; diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index dff0fb8588..1fd84a860e 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -41,7 +41,7 @@ void AudioStreamPlaybackSample::start(float p_from_pos) { ima_adpcm[i].window_ofs = 0; } - seek_pos(p_from_pos); + seek(p_from_pos); sign = 1; active = true; } @@ -61,11 +61,11 @@ int AudioStreamPlaybackSample::get_loop_count() const { return 0; } -float AudioStreamPlaybackSample::get_pos() const { +float AudioStreamPlaybackSample::get_playback_position() const { return float(offset >> MIX_FRAC_BITS) / base->mix_rate; } -void AudioStreamPlaybackSample::seek_pos(float p_time) { +void AudioStreamPlaybackSample::seek(float p_time) { if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM) return; //no seeking in ima-adpcm diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h index 6cb255fedf..fbb8010a9c 100644 --- a/scene/resources/audio_stream_sample.h +++ b/scene/resources/audio_stream_sample.h @@ -71,8 +71,8 @@ public: virtual int get_loop_count() const; //times it looped - virtual float get_pos() const; - virtual void seek_pos(float p_time); + virtual float get_playback_position() const; + virtual void seek(float p_time); virtual void mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames); diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp index be994e3b33..029a9ef0e8 100644 --- a/scene/resources/bit_mask.cpp +++ b/scene/resources/bit_mask.cpp @@ -172,8 +172,8 @@ void BitMap::_bind_methods() { ClassDB::bind_method(D_METHOD("create", "size"), &BitMap::create); ClassDB::bind_method(D_METHOD("create_from_image_alpha", "image"), &BitMap::create_from_image_alpha); - ClassDB::bind_method(D_METHOD("set_bit", "pos", "bit"), &BitMap::set_bit); - ClassDB::bind_method(D_METHOD("get_bit", "pos"), &BitMap::get_bit); + ClassDB::bind_method(D_METHOD("set_bit", "position", "bit"), &BitMap::set_bit); + ClassDB::bind_method(D_METHOD("get_bit", "position"), &BitMap::get_bit); ClassDB::bind_method(D_METHOD("set_bit_rect", "p_rect", "bit"), &BitMap::set_bit_rect); ClassDB::bind_method(D_METHOD("get_true_bit_count"), &BitMap::get_true_bit_count); diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 1066848dd1..daa8fc1874 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -241,7 +241,7 @@ int Curve::set_point_offset(int p_index, float offset) { return i; } -Vector2 Curve::get_point_pos(int p_index) const { +Vector2 Curve::get_point_position(int p_index) const { ERR_FAIL_INDEX_V(p_index, _points.size(), Vector2(0, 0)); return _points[p_index].pos; } @@ -480,11 +480,10 @@ real_t Curve::interpolate_baked(real_t offset) { void Curve::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_point", "pos", "left_tangent", "right_tangent", "left_mode", "right_mode"), - &Curve::add_point, DEFVAL(0), DEFVAL(0), DEFVAL(TANGENT_FREE), DEFVAL(TANGENT_FREE)); + ClassDB::bind_method(D_METHOD("add_point", "position", "left_tangent", "right_tangent", "left_mode", "right_mode"), &Curve::add_point, DEFVAL(0), DEFVAL(0), DEFVAL(TANGENT_FREE), DEFVAL(TANGENT_FREE)); ClassDB::bind_method(D_METHOD("remove_point", "index"), &Curve::remove_point); ClassDB::bind_method(D_METHOD("clear_points"), &Curve::clear_points); - ClassDB::bind_method(D_METHOD("get_point_pos", "index"), &Curve::get_point_pos); + ClassDB::bind_method(D_METHOD("get_point_position", "index"), &Curve::get_point_position); ClassDB::bind_method(D_METHOD("set_point_value", "index", "y"), &Curve::set_point_value); ClassDB::bind_method(D_METHOD("set_point_offset", "index", "offset"), &Curve::set_point_value); ClassDB::bind_method(D_METHOD("interpolate", "offset"), &Curve::interpolate); @@ -539,7 +538,7 @@ void Curve2D::add_point(const Vector2 &p_pos, const Vector2 &p_in, const Vector2 emit_signal(CoreStringNames::get_singleton()->changed); } -void Curve2D::set_point_pos(int p_index, const Vector2 &p_pos) { +void Curve2D::set_point_position(int p_index, const Vector2 &p_pos) { ERR_FAIL_INDEX(p_index, points.size()); @@ -547,7 +546,7 @@ void Curve2D::set_point_pos(int p_index, const Vector2 &p_pos) { baked_cache_dirty = true; emit_signal(CoreStringNames::get_singleton()->changed); } -Vector2 Curve2D::get_point_pos(int p_index) const { +Vector2 Curve2D::get_point_position(int p_index) const { ERR_FAIL_INDEX_V(p_index, points.size(), Vector2()); return points[p_index].pos; @@ -891,12 +890,12 @@ PoolVector2Array Curve2D::tessellate(int p_max_stages, float p_tolerance) const void Curve2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_point_count"), &Curve2D::get_point_count); - ClassDB::bind_method(D_METHOD("add_point", "pos", "in", "out", "atpos"), &Curve2D::add_point, DEFVAL(Vector2()), DEFVAL(Vector2()), DEFVAL(-1)); - ClassDB::bind_method(D_METHOD("set_point_pos", "idx", "pos"), &Curve2D::set_point_pos); - ClassDB::bind_method(D_METHOD("get_point_pos", "idx"), &Curve2D::get_point_pos); - ClassDB::bind_method(D_METHOD("set_point_in", "idx", "pos"), &Curve2D::set_point_in); + ClassDB::bind_method(D_METHOD("add_point", "position", "in", "out", "at_position"), &Curve2D::add_point, DEFVAL(Vector2()), DEFVAL(Vector2()), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("set_point_position", "idx", "position"), &Curve2D::set_point_position); + ClassDB::bind_method(D_METHOD("get_point_position", "idx"), &Curve2D::get_point_position); + ClassDB::bind_method(D_METHOD("set_point_in", "idx", "position"), &Curve2D::set_point_in); ClassDB::bind_method(D_METHOD("get_point_in", "idx"), &Curve2D::get_point_in); - ClassDB::bind_method(D_METHOD("set_point_out", "idx", "pos"), &Curve2D::set_point_out); + ClassDB::bind_method(D_METHOD("set_point_out", "idx", "position"), &Curve2D::set_point_out); ClassDB::bind_method(D_METHOD("get_point_out", "idx"), &Curve2D::get_point_out); ClassDB::bind_method(D_METHOD("remove_point", "idx"), &Curve2D::remove_point); ClassDB::bind_method(D_METHOD("clear_points"), &Curve2D::clear_points); @@ -916,9 +915,6 @@ void Curve2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "bake_interval", PROPERTY_HINT_RANGE, "0.01,512,0.01"), "set_bake_interval", "get_bake_interval"); ADD_PROPERTY(PropertyInfo(Variant::INT, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_data", "_get_data"); - /*ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_out"), "set_points_out","get_points_out"); - ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_pos"), "set_points_pos","get_points_pos"); -*/ } Curve2D::Curve2D() { @@ -955,7 +951,7 @@ void Curve3D::add_point(const Vector3 &p_pos, const Vector3 &p_in, const Vector3 baked_cache_dirty = true; emit_signal(CoreStringNames::get_singleton()->changed); } -void Curve3D::set_point_pos(int p_index, const Vector3 &p_pos) { +void Curve3D::set_point_position(int p_index, const Vector3 &p_pos) { ERR_FAIL_INDEX(p_index, points.size()); @@ -963,7 +959,7 @@ void Curve3D::set_point_pos(int p_index, const Vector3 &p_pos) { baked_cache_dirty = true; emit_signal(CoreStringNames::get_singleton()->changed); } -Vector3 Curve3D::get_point_pos(int p_index) const { +Vector3 Curve3D::get_point_position(int p_index) const { ERR_FAIL_INDEX_V(p_index, points.size(), Vector3()); return points[p_index].pos; @@ -1386,14 +1382,14 @@ PoolVector3Array Curve3D::tessellate(int p_max_stages, float p_tolerance) const void Curve3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_point_count"), &Curve3D::get_point_count); - ClassDB::bind_method(D_METHOD("add_point", "pos", "in", "out", "atpos"), &Curve3D::add_point, DEFVAL(Vector3()), DEFVAL(Vector3()), DEFVAL(-1)); - ClassDB::bind_method(D_METHOD("set_point_pos", "idx", "pos"), &Curve3D::set_point_pos); - ClassDB::bind_method(D_METHOD("get_point_pos", "idx"), &Curve3D::get_point_pos); + ClassDB::bind_method(D_METHOD("add_point", "position", "in", "out", "at_position"), &Curve3D::add_point, DEFVAL(Vector3()), DEFVAL(Vector3()), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("set_point_position", "idx", "position"), &Curve3D::set_point_position); + ClassDB::bind_method(D_METHOD("get_point_position", "idx"), &Curve3D::get_point_position); ClassDB::bind_method(D_METHOD("set_point_tilt", "idx", "tilt"), &Curve3D::set_point_tilt); ClassDB::bind_method(D_METHOD("get_point_tilt", "idx"), &Curve3D::get_point_tilt); - ClassDB::bind_method(D_METHOD("set_point_in", "idx", "pos"), &Curve3D::set_point_in); + ClassDB::bind_method(D_METHOD("set_point_in", "idx", "position"), &Curve3D::set_point_in); ClassDB::bind_method(D_METHOD("get_point_in", "idx"), &Curve3D::get_point_in); - ClassDB::bind_method(D_METHOD("set_point_out", "idx", "pos"), &Curve3D::set_point_out); + ClassDB::bind_method(D_METHOD("set_point_out", "idx", "position"), &Curve3D::set_point_out); ClassDB::bind_method(D_METHOD("get_point_out", "idx"), &Curve3D::get_point_out); ClassDB::bind_method(D_METHOD("remove_point", "idx"), &Curve3D::remove_point); ClassDB::bind_method(D_METHOD("clear_points"), &Curve3D::clear_points); @@ -1414,9 +1410,6 @@ void Curve3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "bake_interval", PROPERTY_HINT_RANGE, "0.01,512,0.01"), "set_bake_interval", "get_bake_interval"); ADD_PROPERTY(PropertyInfo(Variant::INT, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_data", "_get_data"); - /*ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_out"), "set_points_out","get_points_out"); - ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_pos"), "set_points_pos","get_points_pos"); -*/ } Curve3D::Curve3D() { diff --git a/scene/resources/curve.h b/scene/resources/curve.h index 3071aee5de..e7d47f4056 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -92,7 +92,7 @@ public: void set_point_value(int p_index, real_t pos); int set_point_offset(int p_index, float offset); - Vector2 get_point_pos(int p_index) const; + Vector2 get_point_position(int p_index) const; Point get_point(int p_index) const; @@ -180,8 +180,8 @@ protected: public: int get_point_count() const; void add_point(const Vector2 &p_pos, const Vector2 &p_in = Vector2(), const Vector2 &p_out = Vector2(), int p_atpos = -1); - void set_point_pos(int p_index, const Vector2 &p_pos); - Vector2 get_point_pos(int p_index) const; + void set_point_position(int p_index, const Vector2 &p_pos); + Vector2 get_point_position(int p_index) const; void set_point_in(int p_index, const Vector2 &p_in); Vector2 get_point_in(int p_index) const; void set_point_out(int p_index, const Vector2 &p_out); @@ -245,8 +245,8 @@ protected: public: int get_point_count() const; void add_point(const Vector3 &p_pos, const Vector3 &p_in = Vector3(), const Vector3 &p_out = Vector3(), int p_atpos = -1); - void set_point_pos(int p_index, const Vector3 &p_pos); - Vector3 get_point_pos(int p_index) const; + void set_point_position(int p_index, const Vector3 &p_pos); + Vector3 get_point_position(int p_index) const; void set_point_tilt(int p_index, float p_tilt); float get_point_tilt(int p_index) const; void set_point_in(int p_index, const Vector3 &p_in); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 1272e5a946..2fbd5ebdd3 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -879,7 +879,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_icon("minus", "GraphEdit", make_icon(icon_zoom_less_png)); theme->set_icon("reset", "GraphEdit", make_icon(icon_zoom_reset_png)); theme->set_icon("more", "GraphEdit", make_icon(icon_zoom_more_png)); - theme->set_icon("snap", "GraphEdit", make_icon(icon_snap_png)); + theme->set_icon("SnapGrid", "GraphEdit", make_icon(icon_snap_grid_png)); theme->set_stylebox("bg", "GraphEdit", make_stylebox(tree_bg_png, 4, 4, 4, 5)); theme->set_color("grid_minor", "GraphEdit", Color(1, 1, 1, 0.05)); theme->set_color("grid_major", "GraphEdit", Color(1, 1, 1, 0.2)); diff --git a/scene/resources/default_theme/icon_snap.png b/scene/resources/default_theme/icon_snap_grid.png Binary files differindex 93194d34e7..44db9bdfdc 100644 --- a/scene/resources/default_theme/icon_snap.png +++ b/scene/resources/default_theme/icon_snap_grid.png diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h index bed4bdb760..6643b4ccc1 100644 --- a/scene/resources/default_theme/theme_data.h +++ b/scene/resources/default_theme/theme_data.h @@ -182,8 +182,8 @@ static const unsigned char icon_reload_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x6, 0x0, 0x0, 0x0, 0x1f, 0xf3, 0xff, 0x61, 0x0, 0x0, 0x0, 0x6, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x0, 0x0, 0x1, 0x59, 0x49, 0x44, 0x41, 0x54, 0x38, 0x8d, 0xcd, 0x92, 0x31, 0x4b, 0x3, 0x31, 0x18, 0x86, 0x9f, 0x5c, 0xe, 0xec, 0x20, 0x76, 0x70, 0x39, 0xd0, 0xe3, 0xba, 0x74, 0x51, 0x41, 0xdd, 0xfc, 0x7, 0xba, 0xb8, 0x8, 0x52, 0xec, 0x2e, 0x4e, 0x3a, 0x88, 0x3f, 0xa3, 0xa3, 0x53, 0x7, 0x47, 0x67, 0x41, 0x17, 0xdd, 0x9c, 0x5c, 0x3b, 0xd8, 0x82, 0x64, 0x68, 0xca, 0xd5, 0x55, 0x11, 0x3c, 0x1a, 0x87, 0x24, 0x2e, 0xd7, 0x72, 0x9e, 0x9e, 0xab, 0xbe, 0xd3, 0xc7, 0x1b, 0x9e, 0x37, 0xf9, 0xbe, 0x7c, 0xf0, 0xd7, 0x12, 0x3f, 0x99, 0x4a, 0xa9, 0xb9, 0x30, 0xc, 0x8f, 0x84, 0x10, 0x7, 0xc0, 0x5a, 0x6e, 0x3f, 0x3a, 0xe7, 0x2e, 0xad, 0xb5, 0xdd, 0x66, 0xb3, 0xf9, 0x51, 0x19, 0x90, 0xa6, 0xe9, 0x92, 0xb5, 0xf6, 0x6, 0x58, 0xaf, 0xb8, 0xb4, 0x27, 0xa5, 0xdc, 0x8d, 0xe3, 0xf8, 0x19, 0x20, 0x28, 0xdf, 0x5c, 0x80, 0x53, 0x60, 0xdf, 0x18, 0x53, 0x37, 0xc6, 0xd4, 0xbd, 0xf7, 0x7b, 0xc0, 0x13, 0xb0, 0x61, 0xad, 0xbd, 0x56, 0x4a, 0xcd, 0x1, 0x84, 0xc5, 0x80, 0x30, 0xc, 0x8f, 0xa6, 0xb0, 0x94, 0x72, 0x33, 0x8e, 0xe3, 0x97, 0xc2, 0xf1, 0xd5, 0x68, 0x34, 0xba, 0xf7, 0xde, 0xf7, 0x80, 0xd, 0x29, 0xe5, 0x21, 0x70, 0xfe, 0xe5, 0x5, 0x42, 0x88, 0x76, 0x5e, 0x9e, 0x96, 0x60, 0x0, 0x92, 0x24, 0x79, 0x75, 0xce, 0x9d, 0x1, 0x4, 0x41, 0xd0, 0xfe, 0xd6, 0x2, 0xb0, 0x2, 0x60, 0x8c, 0xb9, 0xab, 0xe8, 0x1f, 0x6b, 0xed, 0x6d, 0x5e, 0xae, 0xce, 0x2, 0xb4, 0xd6, 0x17, 0x5a, 0x6b, 0x7, 0xcc, 0x3, 0xd4, 0x6a, 0xb5, 0x37, 0xad, 0xf5, 0xc5, 0x4f, 0x1, 0x41, 0x10, 0x7c, 0x19, 0x7c, 0x90, 0x3, 0xc7, 0xc0, 0xa0, 0xe0, 0xf, 0x72, 0xef, 0x9b, 0x84, 0x10, 0xdb, 0x79, 0xd9, 0x9f, 0x5, 0x44, 0x51, 0x94, 0x9, 0x21, 0x5a, 0x40, 0x6, 0x64, 0x42, 0x88, 0x56, 0x14, 0x45, 0x59, 0x19, 0x1e, 0x8f, 0xc7, 0x8b, 0x52, 0xca, 0xe, 0x80, 0x73, 0xee, 0x12, 0xa, 0xbf, 0x90, 0x24, 0x49, 0x7f, 0x38, 0x1c, 0x1e, 0x3, 0x34, 0x1a, 0x8d, 0x7e, 0x11, 0x54, 0x4a, 0x2d, 0x48, 0x29, 0x77, 0xac, 0xb5, 0x1d, 0xef, 0xfd, 0x32, 0xd0, 0x9b, 0x4c, 0x26, 0x5d, 0xa8, 0xd8, 0xc4, 0xb2, 0xf2, 0xf9, 0x4c, 0x55, 0xbd, 0x48, 0xbf, 0xe8, 0x1d, 0x78, 0x70, 0xce, 0x9d, 0x64, 0x59, 0xb6, 0x35, 0x85, 0xff, 0x87, 0x3e, 0x1, 0x53, 0x7, 0x87, 0x11, 0xd3, 0x3a, 0x9b, 0x9e, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; -static const unsigned char icon_snap_png[] = { - 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x6, 0x0, 0x0, 0x0, 0x1f, 0xf3, 0xff, 0x61, 0x0, 0x0, 0x0, 0x6, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x0, 0x0, 0x0, 0xc2, 0x49, 0x44, 0x41, 0x54, 0x38, 0x8d, 0xad, 0x90, 0xbd, 0xa, 0xc2, 0x30, 0x14, 0x85, 0xbf, 0x5b, 0x5c, 0x23, 0xe8, 0x6c, 0x9f, 0xc1, 0xb7, 0xd0, 0x47, 0xd1, 0x47, 0x70, 0x48, 0xa1, 0x43, 0x57, 0xe9, 0xd3, 0x88, 0x93, 0xef, 0xe0, 0xea, 0x5c, 0x9d, 0x1d, 0xb2, 0x96, 0xc6, 0xa1, 0x9, 0xd4, 0xd8, 0xd8, 0x4a, 0xfd, 0x20, 0x10, 0xee, 0xcf, 0xe1, 0xdc, 0x3, 0x1d, 0x8c, 0x31, 0xd6, 0x18, 0x63, 0x9, 0x88, 0xd5, 0x1, 0x92, 0xbe, 0xe2, 0x2f, 0x4c, 0x16, 0x90, 0x98, 0xb5, 0x21, 0x94, 0x52, 0xf2, 0x17, 0x7, 0x6f, 0x7c, 0xb, 0x2b, 0xc6, 0x64, 0x7, 0xb3, 0xa1, 0x1, 0x5b, 0x14, 0x29, 0x50, 0x2, 0x1b, 0x0, 0x44, 0x2e, 0x34, 0xcd, 0x41, 0xb2, 0xec, 0x6, 0x20, 0xdd, 0x61, 0x6f, 0xdf, 0x7, 0xe4, 0x96, 0xaf, 0xc0, 0x32, 0xd0, 0x7d, 0x2, 0x6b, 0xd1, 0xba, 0x4a, 0xfc, 0xdd, 0x91, 0xdb, 0x4b, 0xb7, 0x7c, 0x2, 0x56, 0xd4, 0x75, 0xa, 0x9c, 0x81, 0x5, 0x70, 0x84, 0xe1, 0xc, 0x5a, 0xdb, 0x75, 0xbd, 0x17, 0xad, 0x1f, 0x92, 0xe7, 0x77, 0x60, 0xe7, 0x7a, 0x5b, 0x80, 0x44, 0x29, 0x25, 0xfe, 0xf5, 0x8, 0x28, 0x0, 0xb7, 0xd8, 0x46, 0xa0, 0x75, 0xe5, 0xbe, 0xf3, 0x31, 0xe, 0x7e, 0x23, 0xcc, 0xc2, 0x3a, 0xc2, 0xb9, 0x58, 0xfd, 0x83, 0xc9, 0x2, 0x63, 0x78, 0x1, 0x4a, 0x50, 0x70, 0x86, 0xcc, 0x86, 0x2, 0x4, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 +static const unsigned char icon_snap_grid_png[] = { + 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x6, 0x0, 0x0, 0x0, 0x1f, 0xf3, 0xff, 0x61, 0x0, 0x0, 0x0, 0x4, 0x73, 0x42, 0x49, 0x54, 0x8, 0x8, 0x8, 0x8, 0x7c, 0x8, 0x64, 0x88, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xe, 0xc4, 0x0, 0x0, 0xe, 0xc4, 0x1, 0x95, 0x2b, 0xe, 0x1b, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x0, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63, 0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x0, 0x0, 0x0, 0xc2, 0x49, 0x44, 0x41, 0x54, 0x38, 0x8d, 0xad, 0x90, 0xbd, 0xa, 0xc2, 0x30, 0x14, 0x85, 0xbf, 0x5b, 0x5c, 0x23, 0xe8, 0x6c, 0x9f, 0xc1, 0xb7, 0xd0, 0x47, 0xd1, 0x47, 0x70, 0x48, 0xa1, 0x43, 0x57, 0xe9, 0xd3, 0x88, 0x93, 0xef, 0xe0, 0xea, 0x5c, 0x9d, 0x1d, 0xb2, 0x96, 0xc6, 0xa1, 0x9, 0xd4, 0xd8, 0xd8, 0x4a, 0xfd, 0x20, 0x10, 0xee, 0xcf, 0xe1, 0xdc, 0x3, 0x1d, 0x8c, 0x31, 0xd6, 0x18, 0x63, 0x9, 0x88, 0xd5, 0x1, 0x92, 0xbe, 0xe2, 0x2f, 0x4c, 0x16, 0x90, 0x98, 0xb5, 0x21, 0x94, 0x52, 0xf2, 0x17, 0x7, 0x6f, 0x7c, 0xb, 0x2b, 0xc6, 0x64, 0x7, 0xb3, 0xa1, 0x1, 0x5b, 0x14, 0x29, 0x50, 0x2, 0x1b, 0x0, 0x44, 0x2e, 0x34, 0xcd, 0x41, 0xb2, 0xec, 0x6, 0x20, 0xdd, 0x61, 0x6f, 0xdf, 0x7, 0xe4, 0x96, 0xaf, 0xc0, 0x32, 0xd0, 0x7d, 0x2, 0x6b, 0xd1, 0xba, 0x4a, 0xfc, 0xdd, 0x91, 0xdb, 0x4b, 0xb7, 0x7c, 0x2, 0x56, 0xd4, 0x75, 0xa, 0x9c, 0x81, 0x5, 0x70, 0x84, 0xe1, 0xc, 0x5a, 0xdb, 0x75, 0xbd, 0x17, 0xad, 0x1f, 0x92, 0xe7, 0x77, 0x60, 0xe7, 0x7a, 0x5b, 0x80, 0x44, 0x29, 0x25, 0xfe, 0xf5, 0x8, 0x28, 0x0, 0xb7, 0xd8, 0x46, 0xa0, 0x75, 0xe5, 0xbe, 0xf3, 0x31, 0xe, 0x7e, 0x23, 0xcc, 0xc2, 0x3a, 0xc2, 0xb9, 0x58, 0xfd, 0x83, 0xc9, 0x2, 0x63, 0x78, 0x1, 0x4a, 0x50, 0x70, 0x86, 0xcc, 0x86, 0x2, 0x4, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; static const unsigned char icon_stop_png[] = { diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 82739b58a0..1ee76a4216 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -397,7 +397,7 @@ unsigned long DynamicFontAtSize::_ft_stream_io(FT_Stream stream, unsigned long o FileAccess *f = (FileAccess *)stream->descriptor.pointer; - if (f->get_pos() != offset) { + if (f->get_position() != offset) { f->seek(offset); } @@ -560,8 +560,23 @@ void DynamicFontAtSize::_update_char(CharType p_char) { int ofs = ((i + tex_y + rect_margin) * tex.texture_size + j + tex_x + rect_margin) * 2; ERR_FAIL_COND(ofs >= tex.imgdata.size()); - wr[ofs + 0] = 255; //grayscale as 1 - wr[ofs + 1] = slot->bitmap.buffer[i * slot->bitmap.width + j]; + switch (slot->bitmap.pixel_mode) { + case FT_PIXEL_MODE_MONO: { + int byte = i * slot->bitmap.pitch + (j >> 3); + int bit = 1 << (7 - (j % 8)); + wr[ofs + 0] = 255; //grayscale as 1 + wr[ofs + 1] = slot->bitmap.buffer[byte] & bit ? 255 : 0; + } break; + case FT_PIXEL_MODE_GRAY: + wr[ofs + 0] = 255; //grayscale as 1 + wr[ofs + 1] = slot->bitmap.buffer[i * slot->bitmap.pitch + j]; + break; + // TODO: FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_BGRA + default: + ERR_EXPLAIN("Font uses unsupported pixel format: " + itos(slot->bitmap.pixel_mode)); + ERR_FAIL(); + break; + } } } } diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index ea75748b3d..2b44ea4554 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -80,13 +80,13 @@ void Font::update_changes() { void Font::_bind_methods() { - ClassDB::bind_method(D_METHOD("draw", "canvas_item", "pos", "string", "modulate", "clip_w"), &Font::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "string", "modulate", "clip_w"), &Font::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("get_ascent"), &Font::get_ascent); ClassDB::bind_method(D_METHOD("get_descent"), &Font::get_descent); ClassDB::bind_method(D_METHOD("get_height"), &Font::get_height); ClassDB::bind_method(D_METHOD("is_distance_field_hint"), &Font::is_distance_field_hint); ClassDB::bind_method(D_METHOD("get_string_size", "string"), &Font::get_string_size); - ClassDB::bind_method(D_METHOD("draw_char", "canvas_item", "pos", "char", "next", "modulate"), &Font::draw_char, DEFVAL(-1), DEFVAL(Color(1, 1, 1))); + ClassDB::bind_method(D_METHOD("draw_char", "canvas_item", "position", "char", "next", "modulate"), &Font::draw_char, DEFVAL(-1), DEFVAL(Color(1, 1, 1))); ClassDB::bind_method(D_METHOD("update_changes"), &Font::update_changes); } diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index abe9a00c3f..c6b434af44 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -268,6 +268,10 @@ void SpatialMaterial::init_shaders() { shader_names->grow = "grow"; + shader_names->proximity_fade_distance = "proximity_fade_distance"; + shader_names->distance_fade_min = "distance_fade_min"; + shader_names->distance_fade_max = "distance_fade_max"; + shader_names->metallic_texture_channel = "metallic_texture_channel"; shader_names->roughness_texture_channel = "roughness_texture_channel"; shader_names->ao_texture_channel = "ao_texture_channel"; @@ -401,6 +405,14 @@ void SpatialMaterial::_update_shader() { code += "uniform float grow;\n"; } + if (proximity_fade_enabled) { + code += "uniform float proximity_fade_distance;\n"; + } + if (distance_fade_enabled) { + code += "uniform float distance_fade_min;\n"; + code += "uniform float distance_fade_max;\n"; + } + if (flags[FLAG_USE_ALPHA_SCISSOR]) { code += "uniform float alpha_scissor_threshold;\n"; } @@ -725,10 +737,21 @@ void SpatialMaterial::_update_shader() { code += "\tALBEDO *= 1.0 - ref_amount;\n"; code += "\tALPHA = 1.0;\n"; - } else if (features[FEATURE_TRANSPARENT] || features[FLAG_USE_ALPHA_SCISSOR]) { + } else if (features[FEATURE_TRANSPARENT] || flags[FLAG_USE_ALPHA_SCISSOR] || distance_fade_enabled || proximity_fade_enabled) { code += "\tALPHA = albedo.a * albedo_tex.a;\n"; } + if (proximity_fade_enabled) { + code += "\tfloat depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV,0.0).r;\n"; + code += "\tvec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV*2.0-1.0,depth_tex*2.0-1.0,1.0);\n"; + code += "\tworld_pos.xyz/=world_pos.w;\n"; + code += "\tALPHA*=clamp(1.0-smoothstep(world_pos.z+proximity_fade_distance,world_pos.z,VERTEX.z),0.0,1.0);\n"; + } + + if (distance_fade_enabled) { + code += "\tALPHA*=clamp(smoothstep(distance_fade_min,distance_fade_max,-VERTEX.z),0.0,1.0);\n"; + } + if (features[FEATURE_RIM]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { code += "\tvec2 rim_tex = triplanar_texture(texture_rim,uv1_power_normal,uv1_triplanar_pos).xy;\n"; @@ -834,10 +857,10 @@ void SpatialMaterial::_update_shader() { code += "\tvec3 detail_norm = mix(NORMALMAP,detail_norm_tex.rgb,detail_tex.a);\n"; code += "\tNORMALMAP = mix(NORMALMAP,detail_norm,detail_mask_tex.r);\n"; code += "\tALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n"; + } - if (flags[FLAG_USE_ALPHA_SCISSOR]) { - code += "\tALPHA_SCISSOR=alpha_scissor_threshold;\n"; - } + if (flags[FLAG_USE_ALPHA_SCISSOR]) { + code += "\tALPHA_SCISSOR=alpha_scissor_threshold;\n"; } code += "}\n"; @@ -1231,6 +1254,14 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { property.usage = 0; } + if (property.name == "proximity_fade_distacne" && !proximity_fade_enabled) { + property.usage = 0; + } + + if ((property.name == "distance_fade_max_distance" || property.name == "distance_fade_min_distance") && !distance_fade_enabled) { + property.usage = 0; + } + if (property.name == "params_alpha_scissor_threshold" && !flags[FLAG_USE_ALPHA_SCISSOR]) { property.usage = 0; } @@ -1526,6 +1557,66 @@ void SpatialMaterial::set_on_top_of_alpha() { set_flag(FLAG_DISABLE_DEPTH_TEST, true); } +void SpatialMaterial::set_proximity_fade(bool p_enable) { + + proximity_fade_enabled = p_enable; + _queue_shader_change(); + _change_notify(); +} + +bool SpatialMaterial::is_proximity_fade_enabled() const { + + return proximity_fade_enabled; +} + +void SpatialMaterial::set_proximity_fade_distance(float p_distance) { + + proximity_fade_distance = p_distance; + VS::get_singleton()->material_set_param(_get_material(), shader_names->proximity_fade_distance, p_distance); +} +float SpatialMaterial::get_proximity_fade_distance() const { + + return proximity_fade_distance; +} + +void SpatialMaterial::set_distance_fade(bool p_enable) { + + distance_fade_enabled = p_enable; + _queue_shader_change(); + _change_notify(); +} +bool SpatialMaterial::is_distance_fade_enabled() const { + + return distance_fade_enabled; +} + +void SpatialMaterial::set_distance_fade_max_distance(float p_distance) { + + distance_fade_max_distance = p_distance; + VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_max, distance_fade_max_distance); +} +float SpatialMaterial::get_distance_fade_max_distance() const { + + return distance_fade_max_distance; +} + +void SpatialMaterial::set_distance_fade_min_distance(float p_distance) { + + distance_fade_min_distance = p_distance; + VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_min, distance_fade_min_distance); +} + +float SpatialMaterial::get_distance_fade_min_distance() const { + + return distance_fade_min_distance; +} + +RID SpatialMaterial::get_shader_rid() const { + + ERR_FAIL_COND_V(!shader_map.has(current_key), RID()); + return shader_map[current_key].shader; +} + void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo); @@ -1672,6 +1763,21 @@ void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_refraction_texture_channel", "channel"), &SpatialMaterial::set_refraction_texture_channel); ClassDB::bind_method(D_METHOD("get_refraction_texture_channel"), &SpatialMaterial::get_refraction_texture_channel); + ClassDB::bind_method(D_METHOD("set_proximity_fade", "enabled"), &SpatialMaterial::set_proximity_fade); + ClassDB::bind_method(D_METHOD("is_proximity_fade_enabled"), &SpatialMaterial::is_proximity_fade_enabled); + + ClassDB::bind_method(D_METHOD("set_proximity_fade_distance", "distance"), &SpatialMaterial::set_proximity_fade_distance); + ClassDB::bind_method(D_METHOD("get_proximity_fade_distance"), &SpatialMaterial::get_proximity_fade_distance); + + ClassDB::bind_method(D_METHOD("set_distance_fade", "enabled"), &SpatialMaterial::set_distance_fade); + ClassDB::bind_method(D_METHOD("is_distance_fade_enabled"), &SpatialMaterial::is_distance_fade_enabled); + + ClassDB::bind_method(D_METHOD("set_distance_fade_max_distance", "distance"), &SpatialMaterial::set_distance_fade_max_distance); + ClassDB::bind_method(D_METHOD("get_distance_fade_max_distance"), &SpatialMaterial::get_distance_fade_max_distance); + + ClassDB::bind_method(D_METHOD("set_distance_fade_min_distance", "distance"), &SpatialMaterial::set_distance_fade_min_distance); + ClassDB::bind_method(D_METHOD("get_distance_fade_min_distance"), &SpatialMaterial::get_distance_fade_min_distance); + ADD_GROUP("Flags", "flags_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_unshaded"), "set_flag", "get_flag", FLAG_UNSHADED); @@ -1795,6 +1901,14 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv2_triplanar"), "set_flag", "get_flag", FLAG_UV2_USE_TRIPLANAR); ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv2_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv2_triplanar_blend_sharpness", "get_uv2_triplanar_blend_sharpness"); + ADD_GROUP("Proximity Fade", "proximity_fade_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "proximity_fade_enable"), "set_proximity_fade", "is_proximity_fade_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "proximity_fade_distance", PROPERTY_HINT_RANGE, "0,4096,0.1"), "set_proximity_fade_distance", "get_proximity_fade_distance"); + ADD_GROUP("Distance Fade", "distance_fade_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distance_fade_enable"), "set_distance_fade", "is_distance_fade_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "distance_fade_min_distance", PROPERTY_HINT_RANGE, "0,4096,0.1"), "set_distance_fade_min_distance", "get_distance_fade_min_distance"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "distance_fade_max_distance", PROPERTY_HINT_RANGE, "0,4096,0.1"), "set_distance_fade_max_distance", "get_distance_fade_max_distance"); + BIND_ENUM_CONSTANT(TEXTURE_ALBEDO); BIND_ENUM_CONSTANT(TEXTURE_METALLIC); BIND_ENUM_CONSTANT(TEXTURE_ROUGHNESS); @@ -1916,6 +2030,12 @@ SpatialMaterial::SpatialMaterial() set_particles_anim_loop(false); set_alpha_scissor_threshold(0.98); + proximity_fade_enabled = false; + distance_fade_enabled = false; + set_proximity_fade_distance(1); + set_distance_fade_min_distance(0); + set_distance_fade_max_distance(10); + set_metallic_texture_channel(TEXTURE_CHANNEL_RED); set_roughness_texture_channel(TEXTURE_CHANNEL_RED); set_ao_texture_channel(TEXTURE_CHANNEL_RED); diff --git a/scene/resources/material.h b/scene/resources/material.h index fdb11982a8..721514f586 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -232,6 +232,8 @@ private: uint64_t deep_parallax : 1; uint64_t billboard_mode : 2; uint64_t grow : 1; + uint64_t proximity_fade : 1; + uint64_t distance_fade : 1; }; uint64_t key; @@ -274,6 +276,8 @@ private: mk.billboard_mode = billboard_mode; mk.deep_parallax = deep_parallax ? 1 : 0; mk.grow = grow_enabled; + mk.proximity_fade = proximity_fade_enabled; + mk.distance_fade = distance_fade_enabled; return mk; } @@ -308,6 +312,9 @@ private: StringName uv1_blend_sharpness; StringName uv2_blend_sharpness; StringName grow; + StringName proximity_fade_distance; + StringName distance_fade_min; + StringName distance_fade_max; StringName metallic_texture_channel; StringName roughness_texture_channel; @@ -370,6 +377,13 @@ private: int deep_parallax_min_layers; int deep_parallax_max_layers; + bool proximity_fade_enabled; + float proximity_fade_distance; + + bool distance_fade_enabled; + float distance_fade_max_distance; + float distance_fade_min_distance; + BlendMode blend_mode; BlendMode detail_blend_mode; DepthDrawMode depth_draw_mode; @@ -535,6 +549,21 @@ public: void set_on_top_of_alpha(); + void set_proximity_fade(bool p_enable); + bool is_proximity_fade_enabled() const; + + void set_proximity_fade_distance(float p_distance); + float get_proximity_fade_distance() const; + + void set_distance_fade(bool p_enable); + bool is_distance_fade_enabled() const; + + void set_distance_fade_max_distance(float p_distance); + float get_distance_fade_max_distance() const; + + void set_distance_fade_min_distance(float p_distance); + float get_distance_fade_min_distance() const; + void set_metallic_texture_channel(TextureChannel p_channel); TextureChannel get_metallic_texture_channel() const; void set_roughness_texture_channel(TextureChannel p_channel); @@ -550,6 +579,8 @@ public: static RID get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass); + RID get_shader_rid() const; + SpatialMaterial(); virtual ~SpatialMaterial(); }; diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index 14e2ef83f8..f0304bfaa5 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -679,7 +679,7 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const String base_path = local_path.get_base_dir(); - uint64_t tag_end = f->get_pos(); + uint64_t tag_end = f->get_position(); while (true) { @@ -741,7 +741,7 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const fw->store_line("[ext_resource path=\"" + path + "\" type=\"" + type + "\" id=" + itos(index) + "]"); - tag_end = f->get_pos(); + tag_end = f->get_position(); } } diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 2ca9a14562..3813854922 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -172,8 +172,8 @@ void ShaderGraph::_bind_methods() { ClassDB::bind_method(D_METHOD("node_add","shader_type","node_type","id"),&ShaderGraph::node_add); ClassDB::bind_method(D_METHOD("node_remove","shader_type","id"),&ShaderGraph::node_remove); - ClassDB::bind_method(D_METHOD("node_set_pos","shader_type","id","pos"),&ShaderGraph::node_set_pos); - ClassDB::bind_method(D_METHOD("node_get_pos","shader_type","id"),&ShaderGraph::node_get_pos); + ClassDB::bind_method(D_METHOD("node_set_position","shader_type","id","position"),&ShaderGraph::node_set_position); + ClassDB::bind_method(D_METHOD("node_get_position","shader_type","id"),&ShaderGraph::node_get_position); ClassDB::bind_method(D_METHOD("node_get_type","shader_type","id"),&ShaderGraph::node_get_type); @@ -501,7 +501,7 @@ void ShaderGraph::node_add(ShaderType p_type, NodeType p_node_type,int p_id) { _request_update(); } -void ShaderGraph::node_set_pos(ShaderType p_type,int p_id, const Vector2& p_pos) { +void ShaderGraph::node_set_position(ShaderType p_type,int p_id, const Vector2& p_pos) { ERR_FAIL_INDEX(p_type,3); ERR_FAIL_COND(!shader[p_type].node_map.has(p_id)); @@ -509,7 +509,7 @@ void ShaderGraph::node_set_pos(ShaderType p_type,int p_id, const Vector2& p_pos) _request_update(); } -Vector2 ShaderGraph::node_get_pos(ShaderType p_type,int p_id) const { +Vector2 ShaderGraph::node_get_position(ShaderType p_type,int p_id) const { ERR_FAIL_INDEX_V(p_type,3,Vector2()); ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Vector2()); @@ -1245,7 +1245,7 @@ Variant ShaderGraph::node_get_state(ShaderType p_type,int p_id) const { ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Variant()); const Node& n = shader[p_type].node_map[p_id]; Dictionary s; - s["pos"]=n.pos; + s["position"]=n.pos; s["param1"]=n.param1; s["param2"]=n.param2; Array keys; @@ -1263,12 +1263,12 @@ void ShaderGraph::node_set_state(ShaderType p_type,int p_id,const Variant& p_sta ERR_FAIL_COND(!shader[p_type].node_map.has(p_id)); Node& n = shader[p_type].node_map[p_id]; Dictionary d = p_state; - ERR_FAIL_COND(!d.has("pos")); + ERR_FAIL_COND(!d.has("position")); ERR_FAIL_COND(!d.has("param1")); ERR_FAIL_COND(!d.has("param2")); ERR_FAIL_COND(!d.has("default_keys")); - n.pos=d["pos"]; + n.pos=d["position"]; n.param1=d["param1"]; n.param2=d["param2"]; Array keys = d["default_keys"]; diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h index 9a74b6c53a..5d9dd7054f 100644 --- a/scene/resources/shader_graph.h +++ b/scene/resources/shader_graph.h @@ -195,8 +195,8 @@ public: void node_add(ShaderType p_type, NodeType p_node_type, int p_id); void node_remove(ShaderType p_which,int p_id); - void node_set_pos(ShaderType p_which,int p_id,const Point2& p_pos); - Point2 node_get_pos(ShaderType p_which,int p_id) const; + void node_set_position(ShaderType p_which,int p_id,const Point2& p_pos); + Point2 node_get_position(ShaderType p_which,int p_id) const; void get_node_list(ShaderType p_which,List<int> *p_node_list) const; NodeType node_get_type(ShaderType p_which,int p_id) const; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 6a9ded9ea3..c202fad1a4 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -70,7 +70,7 @@ void Texture::_bind_methods() { ClassDB::bind_method(D_METHOD("has_alpha"), &Texture::has_alpha); ClassDB::bind_method(D_METHOD("set_flags", "flags"), &Texture::set_flags); ClassDB::bind_method(D_METHOD("get_flags"), &Texture::get_flags); - ClassDB::bind_method(D_METHOD("draw", "canvas_item", "pos", "modulate", "transpose", "normal_map"), &Texture::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map"), &Texture::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map"), &Texture::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true)); ClassDB::bind_method(D_METHOD("get_data"), &Texture::get_data); @@ -488,7 +488,7 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &fla while (mipmaps > 1 && p_size_limit > 0 && (sw > p_size_limit || sh > p_size_limit)) { - f->seek(f->get_pos() + size); + f->seek(f->get_position() + size); mipmaps = f->get_32(); size = f->get_32(); @@ -610,7 +610,7 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &fla ERR_FAIL_V(ERR_FILE_CORRUPT); } - f->seek(f->get_pos() + ofs); + f->seek(f->get_position() + ofs); PoolVector<uint8_t> img_data; img_data.resize(total_size - ofs); diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h index e08be02a07..0f07233185 100644 --- a/scene/resources/video_stream.h +++ b/scene/resources/video_stream.h @@ -55,8 +55,8 @@ public: virtual float get_length() const = 0; - virtual float get_pos() const = 0; - virtual void seek_pos(float p_time) = 0; + virtual float get_playback_position() const = 0; + virtual void seek(float p_time) = 0; virtual void set_audio_track(int p_idx) = 0; |