You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Merge pull request #5533 from Hinsbart/cursor_atex
Can use AtlasTextures as custom mouse cursor.
This commit is contained in:
@@ -4448,12 +4448,13 @@ void VisualServerRaster::cursor_set_rotation(float p_rotation, int p_cursor) {
|
||||
cursors[p_cursor].rot = p_rotation;
|
||||
};
|
||||
|
||||
void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor) {
|
||||
void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor, const Rect2 &p_region) {
|
||||
VS_CHANGED;
|
||||
ERR_FAIL_INDEX(p_cursor, MAX_CURSORS);
|
||||
|
||||
cursors[p_cursor].texture = p_texture;
|
||||
cursors[p_cursor].center = p_center_offset;
|
||||
cursors[p_cursor].region = p_region;
|
||||
};
|
||||
|
||||
void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor) {
|
||||
@@ -7530,8 +7531,13 @@ void VisualServerRaster::_draw_cursors_and_margins() {
|
||||
|
||||
RID tex = cursors[i].texture?cursors[i].texture:default_cursor_texture;
|
||||
ERR_CONTINUE( !tex );
|
||||
Point2 size(texture_get_width(tex), texture_get_height(tex));
|
||||
rasterizer->canvas_draw_rect(Rect2(cursors[i].pos, size), 0, Rect2(), tex, Color(1, 1, 1, 1));
|
||||
if (cursors[i].region.has_no_area()) {
|
||||
Point2 size(texture_get_width(tex), texture_get_height(tex));
|
||||
rasterizer->canvas_draw_rect(Rect2(cursors[i].pos, size), 0, Rect2(), tex, Color(1, 1, 1, 1));
|
||||
} else {
|
||||
Point2 size = cursors[i].region.size;
|
||||
rasterizer->canvas_draw_rect(Rect2(cursors[i].pos, size), Rasterizer::CANVAS_RECT_REGION, cursors[i].region, tex, Color(1, 1, 1, 1));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user