mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Merge pull request #75827 from Kvel2D/fix-custom-cursor-atlas-texture-bug
Fix custom cursor using atlas texture
This commit is contained in:
commit
f7f7250c0d
@ -2654,16 +2654,12 @@ void DisplayServerX11::cursor_set_custom_image(const Ref<Resource> &p_cursor, Cu
|
||||
}
|
||||
|
||||
Ref<Texture2D> texture = p_cursor;
|
||||
ERR_FAIL_COND(!texture.is_valid());
|
||||
Ref<AtlasTexture> atlas_texture = p_cursor;
|
||||
Ref<Image> image;
|
||||
Size2i texture_size;
|
||||
Rect2i 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();
|
||||
@ -2673,17 +2669,16 @@ void DisplayServerX11::cursor_set_custom_image(const Ref<Resource> &p_cursor, Cu
|
||||
|
||||
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());
|
||||
|
||||
|
@ -3328,16 +3328,12 @@ void DisplayServerMacOS::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();
|
||||
@ -3347,17 +3343,16 @@ void DisplayServerMacOS::cursor_set_custom_image(const Ref<Resource> &p_cursor,
|
||||
|
||||
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());
|
||||
|
||||
|
@ -398,16 +398,12 @@ void DisplayServerWeb::cursor_set_custom_image(const Ref<Resource> &p_cursor, Cu
|
||||
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
|
||||
if (p_cursor.is_valid()) {
|
||||
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();
|
||||
@ -417,17 +413,16 @@ void DisplayServerWeb::cursor_set_custom_image(const Ref<Resource> &p_cursor, Cu
|
||||
|
||||
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());
|
||||
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user