diff options
author | Kvel2D <kvelyognaut@gmail.com> | 2023-04-08 16:54:02 +0200 |
---|---|---|
committer | Kvel2D <kvelyognaut@gmail.com> | 2023-04-11 19:16:24 +0200 |
commit | 41f0a523db701e3305d1250d19ba809807dfefeb (patch) | |
tree | eb921fd9eab8148f7b50227683a01937cfb58317 /platform/windows/display_server_windows.cpp | |
parent | c151d3231f8e5d207f64055c60c70967dd5351b5 (diff) | |
download | redot-engine-41f0a523db701e3305d1250d19ba809807dfefeb.tar.gz |
Fix custom cursor using atlas texture
Remove image.is_valid() check
There is already a fail condition and image is not used before that
Move up texture_is_valid() check
Diffstat (limited to 'platform/windows/display_server_windows.cpp')
-rw-r--r-- | platform/windows/display_server_windows.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 388a799c1c..6ff928580a 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1755,36 +1755,30 @@ void DisplayServerWindows::cursor_set_custom_image(const Ref<Resource> &p_cursor } Ref<Texture2D> texture = p_cursor; + ERR_FAIL_COND(!texture.is_valid()); Ref<AtlasTexture> atlas_texture = p_cursor; - Ref<Image> image; Size2 texture_size; Rect2 atlas_rect; - if (texture.is_valid()) { - image = texture->get_image(); - } - - if (!image.is_valid() && atlas_texture.is_valid()) { + if (atlas_texture.is_valid()) { texture = atlas_texture->get_atlas(); atlas_rect.size.width = texture->get_width(); atlas_rect.size.height = texture->get_height(); atlas_rect.position.x = atlas_texture->get_region().position.x; atlas_rect.position.y = atlas_texture->get_region().position.y; - texture_size.width = atlas_texture->get_region().size.x; texture_size.height = atlas_texture->get_region().size.y; - } else if (image.is_valid()) { + } else { texture_size.width = texture->get_width(); texture_size.height = texture->get_height(); } - ERR_FAIL_COND(!texture.is_valid()); ERR_FAIL_COND(p_hotspot.x < 0 || p_hotspot.y < 0); ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256); ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height); - image = texture->get_image(); + Ref<Image> image = texture->get_image(); ERR_FAIL_COND(!image.is_valid()); |