diff options
-rw-r--r-- | core/variant_call.cpp | 2 | ||||
-rw-r--r-- | doc/classes/Sprite.xml | 3 | ||||
-rw-r--r-- | doc/classes/Sprite3D.xml | 3 | ||||
-rw-r--r-- | editor/editor_fonts.cpp | 14 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 15 | ||||
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 10 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.h | 2 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Basis.cs | 3 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/NodePath.cs | 2 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Quat.cs | 12 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Transform.cs | 2 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Vector2.cs | 2 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Vector3.cs | 2 | ||||
-rw-r--r-- | modules/websocket/wsl_client.cpp | 12 | ||||
-rw-r--r-- | scene/2d/sprite.cpp | 16 | ||||
-rw-r--r-- | scene/2d/sprite.h | 3 | ||||
-rw-r--r-- | scene/3d/sprite_3d.cpp | 18 | ||||
-rw-r--r-- | scene/3d/sprite_3d.h | 3 | ||||
-rw-r--r-- | scene/gui/control.cpp | 2 |
20 files changed, 88 insertions, 40 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 377cc889b8..1f6e5bb653 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -914,7 +914,7 @@ struct _VariantCall { static void Quat_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Quat(((Vector3)(*p_args[0])), ((float)(*p_args[1]))); + r_ret = Quat(((Vector3)(*p_args[0])), ((real_t)(*p_args[1]))); } static void Quat_init3(Variant &r_ret, const Variant **p_args) { diff --git a/doc/classes/Sprite.xml b/doc/classes/Sprite.xml index e5aea961f4..35db0b3762 100644 --- a/doc/classes/Sprite.xml +++ b/doc/classes/Sprite.xml @@ -46,6 +46,9 @@ <member name="frame" type="int" setter="set_frame" getter="get_frame" default="0"> Current frame to display from sprite sheet. [member vframes] or [member hframes] must be greater than 1. </member> + <member name="frame_coords" type="Vector2" setter="set_frame_coords" getter="get_frame_coords"> + Coordinates of the frame to display from sprite sheet. This is as an alias for the [member frame] property. [member vframes] or [member hframes] must be greater than 1. + </member> <member name="hframes" type="int" setter="set_hframes" getter="get_hframes" default="1"> The number of columns in the sprite sheet. </member> diff --git a/doc/classes/Sprite3D.xml b/doc/classes/Sprite3D.xml index 9a51302bf1..be15b066aa 100644 --- a/doc/classes/Sprite3D.xml +++ b/doc/classes/Sprite3D.xml @@ -14,6 +14,9 @@ <member name="frame" type="int" setter="set_frame" getter="get_frame" default="0"> Current frame to display from sprite sheet. [member vframes] or [member hframes] must be greater than 1. </member> + <member name="frame_coords" type="Vector2" setter="set_frame_coords" getter="get_frame_coords"> + Coordinates of the frame to display from sprite sheet. This is as an alias for the [member frame] property. [member vframes] or [member hframes] must be greater than 1. + </member> <member name="hframes" type="int" setter="set_hframes" getter="get_hframes" default="1"> The number of columns in the sprite sheet. </member> diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 40ecffbb3b..73438ffc0c 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -93,8 +93,8 @@ void editor_register_fonts(Ref<Theme> p_theme) { /* Custom font */ - bool font_antialiased = (bool)EditorSettings::get_singleton()->get("interface/editor/main_font_antialiased"); - DynamicFontData::Hinting font_hinting = (DynamicFontData::Hinting)(int)EditorSettings::get_singleton()->get("interface/editor/main_font_hinting"); + bool font_antialiased = (bool)EditorSettings::get_singleton()->get("interface/editor/font_antialiased"); + DynamicFontData::Hinting font_hinting = (DynamicFontData::Hinting)(int)EditorSettings::get_singleton()->get("interface/editor/font_hinting"); String custom_font_path = EditorSettings::get_singleton()->get("interface/editor/main_font"); Ref<DynamicFontData> CustomFont; @@ -125,13 +125,11 @@ void editor_register_fonts(Ref<Theme> p_theme) { /* Custom source code font */ String custom_font_path_source = EditorSettings::get_singleton()->get("interface/editor/code_font"); - bool font_source_antialiased = (bool)EditorSettings::get_singleton()->get("interface/editor/code_font_antialiased"); - DynamicFontData::Hinting font_source_hinting = (DynamicFontData::Hinting)(int)EditorSettings::get_singleton()->get("interface/editor/code_font_hinting"); Ref<DynamicFontData> CustomFontSource; if (custom_font_path_source.length() > 0 && dir->file_exists(custom_font_path_source)) { CustomFontSource.instance(); - CustomFontSource->set_antialiased(font_source_antialiased); - CustomFontSource->set_hinting(font_source_hinting); + CustomFontSource->set_antialiased(font_antialiased); + CustomFontSource->set_hinting(font_hinting); CustomFontSource->set_font_path(custom_font_path_source); } else { EditorSettings::get_singleton()->set_manually("interface/editor/code_font", ""); @@ -201,8 +199,8 @@ void editor_register_fonts(Ref<Theme> p_theme) { Ref<DynamicFontData> dfmono; dfmono.instance(); - dfmono->set_antialiased(font_source_antialiased); - dfmono->set_hinting(font_source_hinting); + dfmono->set_antialiased(font_antialiased); + dfmono->set_hinting(font_hinting); dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 948a86924b..45000517cb 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -321,18 +321,15 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::REAL, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/main_font_size", 14); hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/editor/main_font_antialiased", true); - _initial_set("interface/editor/main_font_hinting", 2); - hints["interface/editor/main_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/main_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT); + _initial_set("interface/editor/code_font_size", 14); + hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT); + _initial_set("interface/editor/font_antialiased", true); + _initial_set("interface/editor/font_hinting", 2); + hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/main_font", ""); hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/main_font_bold", ""); hints["interface/editor/main_font_bold"] = PropertyInfo(Variant::STRING, "interface/editor/main_font_bold", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT); - _initial_set("interface/editor/code_font_size", 14); - hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT); - _initial_set("interface/editor/code_font_antialiased", true); - _initial_set("interface/editor/code_font_hinting", 2); - hints["interface/editor/code_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/code_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/code_font", ""); hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/dim_editor_on_dialog_popup", true); @@ -614,7 +611,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { /* Extra config */ _initial_set("project_manager/sorting_order", 0); - hints["project_manager/sorting_order"] = PropertyInfo(Variant::INT, "project_manager/sorting_order", PROPERTY_HINT_ENUM, "Name,Last Modified"); + hints["project_manager/sorting_order"] = PropertyInfo(Variant::INT, "project_manager/sorting_order", PROPERTY_HINT_ENUM, "Name,Path,Last Modified"); if (p_extra_config.is_valid()) { diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 8246e74814..c9c5b3818f 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -986,7 +986,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { Ref<SurfaceTool> st; st.instance(); st->create_from_triangle_arrays(array); - if (p.has("targets")) { + if (!p.has("targets")) { //morph targets should not be reindexed, as array size might differ //removing indices is the best bet here st->deindex(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 19199f37ef..92dc3e7f0d 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1058,9 +1058,9 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve return false; } -bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { +bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bool p_already_accepted) { Ref<InputEventMouseButton> b = p_event; - if (b.is_valid()) { + if (b.is_valid() && !p_already_accepted) { bool pan_on_scroll = bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan")) && !b->get_control(); if (b->is_pressed() && b->get_button_index() == BUTTON_WHEEL_DOWN) { @@ -1162,14 +1162,14 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { } Ref<InputEventMagnifyGesture> magnify_gesture = p_event; - if (magnify_gesture.is_valid()) { + if (magnify_gesture.is_valid() && !p_already_accepted) { // Zoom gesture _zoom_on_position(zoom * magnify_gesture->get_factor(), magnify_gesture->get_position()); return true; } Ref<InputEventPanGesture> pan_gesture = p_event; - if (pan_gesture.is_valid()) { + if (pan_gesture.is_valid() && !p_already_accepted) { // Pan gesture const Vector2 delta = (int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom) * pan_gesture->get_delta(); view_offset.x += delta.x; @@ -2268,7 +2268,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { } } - accepted = (_gui_input_zoom_or_pan(p_event) || accepted); + accepted = (_gui_input_zoom_or_pan(p_event, accepted) || accepted); if (accepted) accept_event(); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 2a85b20424..553ded6b14 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -466,7 +466,7 @@ private: bool _gui_input_resize(const Ref<InputEvent> &p_event); bool _gui_input_rotate(const Ref<InputEvent> &p_event); bool _gui_input_select(const Ref<InputEvent> &p_event); - bool _gui_input_zoom_or_pan(const Ref<InputEvent> &p_event); + bool _gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bool p_already_accepted); bool _gui_input_rulers_and_guides(const Ref<InputEvent> &p_event); bool _gui_input_hover(const Ref<InputEvent> &p_event); diff --git a/modules/mono/glue/Managed/Files/Basis.cs b/modules/mono/glue/Managed/Files/Basis.cs index 9cc31a0557..5a6a5ff658 100644 --- a/modules/mono/glue/Managed/Files/Basis.cs +++ b/modules/mono/glue/Managed/Files/Basis.cs @@ -225,7 +225,7 @@ namespace Godot return orthonormalizedBasis.Quat(); } - internal void SetQuantScale(Quat quat, Vector3 scale) + internal void SetQuatScale(Quat quat, Vector3 scale) { SetDiagonal(scale); Rotate(quat); @@ -241,7 +241,6 @@ namespace Godot Row0 = new Vector3(diagonal.x, 0, 0); Row1 = new Vector3(0, diagonal.y, 0); Row2 = new Vector3(0, 0, diagonal.z); - } public real_t Determinant() diff --git a/modules/mono/glue/Managed/Files/NodePath.cs b/modules/mono/glue/Managed/Files/NodePath.cs index 94a4ed1de9..4de4e1e6a9 100644 --- a/modules/mono/glue/Managed/Files/NodePath.cs +++ b/modules/mono/glue/Managed/Files/NodePath.cs @@ -55,7 +55,7 @@ namespace Godot get { return ptr; } } - public NodePath() : this(string.Empty) { } + public NodePath() : this(string.Empty) {} public NodePath(string path) { diff --git a/modules/mono/glue/Managed/Files/Quat.cs b/modules/mono/glue/Managed/Files/Quat.cs index 0d4349084a..f1d97b9b5c 100644 --- a/modules/mono/glue/Managed/Files/Quat.cs +++ b/modules/mono/glue/Managed/Files/Quat.cs @@ -95,6 +95,7 @@ namespace Godot return this / Length; } + [Obsolete("Set is deprecated. Use the Quat(" + nameof(real_t) + ", " + nameof(real_t) + ", " + nameof(real_t) + ", " + nameof(real_t) + ") constructor instead.", error: true)] public void Set(real_t x, real_t y, real_t z, real_t w) { this.x = x; @@ -103,16 +104,19 @@ namespace Godot this.w = w; } + [Obsolete("Set is deprecated. Use the Quat(" + nameof(Quat) + ") constructor instead.", error: true)] public void Set(Quat q) { this = q; } + [Obsolete("SetAxisAngle is deprecated. Use the Quat(" + nameof(Vector3) + ", " + nameof(real_t) + ") constructor instead.", error: true)] public void SetAxisAngle(Vector3 axis, real_t angle) { this = new Quat(axis, angle); } + [Obsolete("SetEuler is deprecated. Use the Quat(" + nameof(Vector3) + ") constructor instead.", error: true)] public void SetEuler(Vector3 eulerYXZ) { this = new Quat(eulerYXZ); @@ -229,9 +233,9 @@ namespace Godot public Quat(Vector3 eulerYXZ) { - real_t half_a1 = eulerYXZ.y * (real_t)0.5; - real_t half_a2 = eulerYXZ.x * (real_t)0.5; - real_t half_a3 = eulerYXZ.z * (real_t)0.5; + real_t half_a1 = eulerYXZ.y * 0.5f; + real_t half_a2 = eulerYXZ.x * 0.5f; + real_t half_a3 = eulerYXZ.z * 0.5f; // R = Y(a1).X(a2).Z(a3) convention for Euler angles. // Conversion to quaternion as listed in https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19770024290.pdf (page A-6) @@ -246,7 +250,7 @@ namespace Godot x = sin_a1 * cos_a2 * sin_a3 + cos_a1 * sin_a2 * cos_a3; y = sin_a1 * cos_a2 * cos_a3 - cos_a1 * sin_a2 * sin_a3; - z = -sin_a1 * sin_a2 * cos_a3 + cos_a1 * cos_a2 * sin_a3; + z = cos_a1 * cos_a2 * sin_a3 - sin_a1 * sin_a2 * cos_a3; w = sin_a1 * sin_a2 * sin_a3 + cos_a1 * cos_a2 * cos_a3; } diff --git a/modules/mono/glue/Managed/Files/Transform.cs b/modules/mono/glue/Managed/Files/Transform.cs index bd79144873..de70ccbe98 100644 --- a/modules/mono/glue/Managed/Files/Transform.cs +++ b/modules/mono/glue/Managed/Files/Transform.cs @@ -33,7 +33,7 @@ namespace Godot Vector3 destinationLocation = transform.origin; var interpolated = new Transform(); - interpolated.basis.SetQuantScale(sourceRotation.Slerp(destinationRotation, c).Normalized(), sourceScale.LinearInterpolate(destinationScale, c)); + interpolated.basis.SetQuatScale(sourceRotation.Slerp(destinationRotation, c).Normalized(), sourceScale.LinearInterpolate(destinationScale, c)); interpolated.origin = sourceLocation.LinearInterpolate(destinationLocation, c); return interpolated; diff --git a/modules/mono/glue/Managed/Files/Vector2.cs b/modules/mono/glue/Managed/Files/Vector2.cs index a7f26283a7..3fb40d8a61 100644 --- a/modules/mono/glue/Managed/Files/Vector2.cs +++ b/modules/mono/glue/Managed/Files/Vector2.cs @@ -222,11 +222,13 @@ namespace Godot return new Vector2(Mathf.Round(x), Mathf.Round(y)); } + [Obsolete("Set is deprecated. Use the Vector2(" + nameof(real_t) + ", " + nameof(real_t) + ") constructor instead.", error: true)] public void Set(real_t x, real_t y) { this.x = x; this.y = y; } + [Obsolete("Set is deprecated. Use the Vector2(" + nameof(Vector2) + ") constructor instead.", error: true)] public void Set(Vector2 v) { x = v.x; diff --git a/modules/mono/glue/Managed/Files/Vector3.cs b/modules/mono/glue/Managed/Files/Vector3.cs index 16803ae55c..68601da1e7 100644 --- a/modules/mono/glue/Managed/Files/Vector3.cs +++ b/modules/mono/glue/Managed/Files/Vector3.cs @@ -248,12 +248,14 @@ namespace Godot return new Basis(axis, phi).Xform(this); } + [Obsolete("Set is deprecated. Use the Vector3(" + nameof(real_t) + ", " + nameof(real_t) + ", " + nameof(real_t) + ") constructor instead.", error: true)] public void Set(real_t x, real_t y, real_t z) { this.x = x; this.y = y; this.z = z; } + [Obsolete("Set is deprecated. Use the Vector3(" + nameof(Vector3) + ") constructor instead.", error: true)] public void Set(Vector3 v) { x = v.x; diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp index 86374e8f80..af75f2a320 100644 --- a/modules/websocket/wsl_client.cpp +++ b/modules/websocket/wsl_client.cpp @@ -190,8 +190,8 @@ Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port, Error err = _tcp->connect_to_host(addr, p_port); if (err != OK) { - _on_error(); _tcp->disconnect_from_host(); + _on_error(); return err; } _connection = _tcp; @@ -230,8 +230,8 @@ void WSLClient::poll() { if (_peer->is_connected_to_host()) { _peer->poll(); if (!_peer->is_connected_to_host()) { - _on_disconnect(_peer->close_code != -1); disconnect_from_host(); + _on_disconnect(_peer->close_code != -1); } return; } @@ -242,8 +242,8 @@ void WSLClient::poll() { switch (_tcp->get_status()) { case StreamPeerTCP::STATUS_NONE: // Clean close - _on_error(); disconnect_from_host(); + _on_error(); break; case StreamPeerTCP::STATUS_CONNECTED: { Ref<StreamPeerSSL> ssl; @@ -255,8 +255,8 @@ void WSLClient::poll() { ERR_FAIL_COND(ssl.is_null()); ssl->set_blocking_handshake_enabled(false); if (ssl->connect_to_stream(_tcp, verify_ssl, _host) != OK) { - _on_error(); disconnect_from_host(); + _on_error(); return; } _connection = ssl; @@ -268,8 +268,8 @@ void WSLClient::poll() { if (ssl->get_status() == StreamPeerSSL::STATUS_HANDSHAKING) return; // Need more polling. else if (ssl->get_status() != StreamPeerSSL::STATUS_CONNECTED) { - _on_error(); disconnect_from_host(); + _on_error(); return; // Error. } } @@ -277,8 +277,8 @@ void WSLClient::poll() { _do_handshake(); } break; case StreamPeerTCP::STATUS_ERROR: - _on_error(); disconnect_from_host(); + _on_error(); break; case StreamPeerTCP::STATUS_CONNECTING: break; // Wait for connection diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index dbe47e89ec..d7a8005187 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -259,6 +259,7 @@ void Sprite::set_frame(int p_frame) { frame = p_frame; _change_notify("frame"); + _change_notify("frame_coords"); emit_signal(SceneStringNames::get_singleton()->frame_changed); } @@ -267,6 +268,17 @@ int Sprite::get_frame() const { return frame; } +void Sprite::set_frame_coords(const Vector2 &p_coord) { + ERR_FAIL_INDEX(int(p_coord.x), vframes); + ERR_FAIL_INDEX(int(p_coord.y), hframes); + + set_frame(int(p_coord.y) * hframes + int(p_coord.x)); +} + +Vector2 Sprite::get_frame_coords() const { + return Vector2(frame % hframes, frame / hframes); +} + void Sprite::set_vframes(int p_amount) { ERR_FAIL_COND(p_amount < 1); @@ -420,6 +432,9 @@ void Sprite::_bind_methods() { ClassDB::bind_method(D_METHOD("set_frame", "frame"), &Sprite::set_frame); ClassDB::bind_method(D_METHOD("get_frame"), &Sprite::get_frame); + ClassDB::bind_method(D_METHOD("set_frame_coords", "coords"), &Sprite::set_frame_coords); + ClassDB::bind_method(D_METHOD("get_frame_coords"), &Sprite::get_frame_coords); + ClassDB::bind_method(D_METHOD("set_vframes", "vframes"), &Sprite::set_vframes); ClassDB::bind_method(D_METHOD("get_vframes"), &Sprite::get_vframes); @@ -442,6 +457,7 @@ void Sprite::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "frame_coords", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_frame_coords", "get_frame_coords"); ADD_GROUP("Region", "region_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_enabled"), "set_region", "is_region"); diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h index e38db3a299..490db31cdb 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite.h @@ -110,6 +110,9 @@ public: void set_frame(int p_frame); int get_frame() const; + void set_frame_coords(const Vector2 &p_row); + Vector2 get_frame_coords() const; + void set_vframes(int p_amount); int get_vframes() const; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index b39762fde8..fc5523633d 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -564,6 +564,9 @@ void Sprite3D::set_frame(int p_frame) { frame = p_frame; _queue_update(); + + _change_notify("frame"); + _change_notify("frame_coords"); emit_signal(SceneStringNames::get_singleton()->frame_changed); } @@ -572,6 +575,17 @@ int Sprite3D::get_frame() const { return frame; } +void Sprite3D::set_frame_coords(const Vector2 &p_coord) { + ERR_FAIL_INDEX(int(p_coord.x), vframes); + ERR_FAIL_INDEX(int(p_coord.y), hframes); + + set_frame(int(p_coord.y) * hframes + int(p_coord.x)); +} + +Vector2 Sprite3D::get_frame_coords() const { + return Vector2(frame % hframes, frame / hframes); +} + void Sprite3D::set_vframes(int p_amount) { ERR_FAIL_COND(p_amount < 1); @@ -648,6 +662,9 @@ void Sprite3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_frame", "frame"), &Sprite3D::set_frame); ClassDB::bind_method(D_METHOD("get_frame"), &Sprite3D::get_frame); + ClassDB::bind_method(D_METHOD("set_frame_coords", "coords"), &Sprite3D::set_frame_coords); + ClassDB::bind_method(D_METHOD("get_frame_coords"), &Sprite3D::get_frame_coords); + ClassDB::bind_method(D_METHOD("set_vframes", "vframes"), &Sprite3D::set_vframes); ClassDB::bind_method(D_METHOD("get_vframes"), &Sprite3D::get_vframes); @@ -659,6 +676,7 @@ void Sprite3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "frame_coords", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_frame_coords", "get_frame_coords"); ADD_GROUP("Region", "region_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_enabled"), "set_region", "is_region"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 0e086ef31e..5ae9b153f9 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -173,6 +173,9 @@ public: void set_frame(int p_frame); int get_frame() const; + void set_frame_coords(const Vector2 &p_row); + Vector2 get_frame_coords() const; + void set_vframes(int p_amount); int get_vframes() const; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 1d6f3dc782..5ec6c68163 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -289,7 +289,7 @@ void Control::_update_minimum_size() { Size2 minsize = get_combined_minimum_size(); if (minsize.x > data.size_cache.x || minsize.y > data.size_cache.y) { - set_size(data.size_cache); + _size_changed(); } data.updating_last_minimum_size = false; |