parent
a28bf56ef9
commit
91add16300
|
@ -30,6 +30,7 @@
|
||||||
#include "servers/visual_server.h"
|
#include "servers/visual_server.h"
|
||||||
#include "os/os.h"
|
#include "os/os.h"
|
||||||
#include "input_map.h"
|
#include "input_map.h"
|
||||||
|
#include "scene/resources/texture.h"
|
||||||
|
|
||||||
void InputDefault::SpeedTrack::update(const Vector2& p_delta_p) {
|
void InputDefault::SpeedTrack::update(const Vector2& p_delta_p) {
|
||||||
|
|
||||||
|
@ -463,9 +464,11 @@ void InputDefault::set_custom_mouse_cursor(const RES& p_cursor,const Vector2& p_
|
||||||
set_mouse_mode(MOUSE_MODE_VISIBLE);
|
set_mouse_mode(MOUSE_MODE_VISIBLE);
|
||||||
VisualServer::get_singleton()->cursor_set_visible(false);
|
VisualServer::get_singleton()->cursor_set_visible(false);
|
||||||
} else {
|
} else {
|
||||||
|
Ref<AtlasTexture> atex = custom_cursor;
|
||||||
|
Rect2 region = atex.is_valid() ? atex->get_region() : Rect2();
|
||||||
set_mouse_mode(MOUSE_MODE_HIDDEN);
|
set_mouse_mode(MOUSE_MODE_HIDDEN);
|
||||||
VisualServer::get_singleton()->cursor_set_visible(true);
|
VisualServer::get_singleton()->cursor_set_visible(true);
|
||||||
VisualServer::get_singleton()->cursor_set_texture(custom_cursor->get_rid(),p_hotspot);
|
VisualServer::get_singleton()->cursor_set_texture(custom_cursor->get_rid(),p_hotspot, 0, region);
|
||||||
VisualServer::get_singleton()->cursor_set_pos(get_mouse_pos());
|
VisualServer::get_singleton()->cursor_set_pos(get_mouse_pos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4448,12 +4448,13 @@ void VisualServerRaster::cursor_set_rotation(float p_rotation, int p_cursor) {
|
||||||
cursors[p_cursor].rot = p_rotation;
|
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;
|
VS_CHANGED;
|
||||||
ERR_FAIL_INDEX(p_cursor, MAX_CURSORS);
|
ERR_FAIL_INDEX(p_cursor, MAX_CURSORS);
|
||||||
|
|
||||||
cursors[p_cursor].texture = p_texture;
|
cursors[p_cursor].texture = p_texture;
|
||||||
cursors[p_cursor].center = p_center_offset;
|
cursors[p_cursor].center = p_center_offset;
|
||||||
|
cursors[p_cursor].region = p_region;
|
||||||
};
|
};
|
||||||
|
|
||||||
void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor) {
|
void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor) {
|
||||||
|
@ -7538,8 +7539,13 @@ void VisualServerRaster::_draw_cursors_and_margins() {
|
||||||
|
|
||||||
RID tex = cursors[i].texture?cursors[i].texture:default_cursor_texture;
|
RID tex = cursors[i].texture?cursors[i].texture:default_cursor_texture;
|
||||||
ERR_CONTINUE( !tex );
|
ERR_CONTINUE( !tex );
|
||||||
Point2 size(texture_get_width(tex), texture_get_height(tex));
|
if (cursors[i].region.has_no_area()) {
|
||||||
rasterizer->canvas_draw_rect(Rect2(cursors[i].pos, size), 0, Rect2(), tex, Color(1, 1, 1, 1));
|
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));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -544,10 +544,12 @@ class VisualServerRaster : public VisualServer {
|
||||||
RID texture;
|
RID texture;
|
||||||
Point2 center;
|
Point2 center;
|
||||||
bool visible;
|
bool visible;
|
||||||
|
Rect2 region;
|
||||||
Cursor() {
|
Cursor() {
|
||||||
|
|
||||||
rot = 0;
|
rot = 0;
|
||||||
visible = false;
|
visible = false;
|
||||||
|
region = Rect2();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1240,7 +1242,7 @@ public:
|
||||||
|
|
||||||
/* CURSOR */
|
/* CURSOR */
|
||||||
virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0); // radians
|
virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0); // radians
|
||||||
virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor=0);
|
virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor=0, const Rect2 &p_region=Rect2());
|
||||||
virtual void cursor_set_visible(bool p_visible, int p_cursor = 0);
|
virtual void cursor_set_visible(bool p_visible, int p_cursor = 0);
|
||||||
virtual void cursor_set_pos(const Point2& p_pos, int p_cursor = 0);
|
virtual void cursor_set_pos(const Point2& p_pos, int p_cursor = 0);
|
||||||
|
|
||||||
|
|
|
@ -680,7 +680,7 @@ public:
|
||||||
|
|
||||||
/* CURSOR */
|
/* CURSOR */
|
||||||
FUNC2(cursor_set_rotation,float , int ); // radians
|
FUNC2(cursor_set_rotation,float , int ); // radians
|
||||||
FUNC3(cursor_set_texture,RID , const Point2 &, int );
|
FUNC4(cursor_set_texture,RID , const Point2 &, int, const Rect2 &);
|
||||||
FUNC2(cursor_set_visible,bool , int );
|
FUNC2(cursor_set_visible,bool , int );
|
||||||
FUNC2(cursor_set_pos,const Point2& , int );
|
FUNC2(cursor_set_pos,const Point2& , int );
|
||||||
|
|
||||||
|
|
|
@ -1110,7 +1110,7 @@ public:
|
||||||
|
|
||||||
/* CURSOR */
|
/* CURSOR */
|
||||||
virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0)=0; // radians
|
virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0)=0; // radians
|
||||||
virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor=0)=0;
|
virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor=0, const Rect2 &p_region=Rect2())=0;
|
||||||
virtual void cursor_set_visible(bool p_visible, int p_cursor = 0)=0;
|
virtual void cursor_set_visible(bool p_visible, int p_cursor = 0)=0;
|
||||||
virtual void cursor_set_pos(const Point2& p_pos, int p_cursor = 0)=0;
|
virtual void cursor_set_pos(const Point2& p_pos, int p_cursor = 0)=0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue