diff --git a/res/graphics/crosshair.ase b/res/graphics/crosshair.ase index dbc07ae2..e7242d1c 100644 --- a/res/graphics/crosshair.ase +++ b/res/graphics/crosshair.ase @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dabc422b506ea27dc447e16ba9450e8f3f69e7237a0c055c97b247dc3223d927 +oid sha256:9c42911c8c2ff227836062a44ce5a46eaeb020457e3df482e3ac1d54ca26ccac size 345 diff --git a/src/user.c b/src/user.c index a4057cf6..a650ef99 100644 --- a/src/user.c +++ b/src/user.c @@ -527,9 +527,6 @@ INTERNAL void user_update(void) } if (L.debug_camera) { - sys_window_cursor_disable_clip(L.window); - sys_window_cursor_show(L.window); - /* Pan view */ if (L.bind_states[USER_BIND_KIND_PAN].is_held) { if (!L.debug_camera_panning) { @@ -567,10 +564,6 @@ INTERNAL void user_update(void) L.world_view = xform_translate(L.world_view, v2_neg(world_cursor)); } } else { - /* Keep cursor invisible and in screen */ - sys_window_cursor_hide(L.window); - sys_window_cursor_enable_clip(L.window, RECT(0, 0, L.screen_size.x, L.screen_size.y)); - struct v2 center = active_camera->world_xform.og; f32 rot = xform_get_rotation(active_camera->world_xform); f32 zoom = active_camera->camera_zoom; @@ -786,17 +779,25 @@ INTERNAL void user_update(void) } } - /* Draw crosshair */ + /* Draw crosshair or enable cursor */ if (!L.debug_camera) { struct v2 crosshair_pos = L.screen_cursor; u32 tint = RGBA_F(1, 1, 1, 0.5); + struct v2 size = V2(0, 0); struct texture *t = texture_load_async(STR("res/graphics/crosshair.ase")); if (t) { + size = t->size; struct xform xf = XFORM_TRS(.t = crosshair_pos, .s = t->size); struct quad quad = quad_mul_xform(QUAD_UNIT_SQUARE_CENTERED, xf); draw_texture_quad(L.screen_canvas, DRAW_TEXTURE_PARAMS(.texture = t, .tint = tint), quad); } + + sys_window_cursor_hide(L.window); + sys_window_cursor_enable_clip(L.window, RECT(size.x / 2, size.y / 2, L.screen_size.x - size.x, L.screen_size.y - size.y)); + } else { + sys_window_cursor_disable_clip(L.window); + sys_window_cursor_show(L.window); } /* ========================== *