snap window cursor to crosshair when looking stops
This commit is contained in:
parent
e457dd392a
commit
a6a5e27cb9
@ -1960,9 +1960,18 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
WND_SetCursor(window_frame, WND_CursorKind_Hidden);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prev_frame->is_looking)
|
||||
{
|
||||
// Snap cursor to crosshair
|
||||
frame->screen_cursor = prev_frame->screen_cursor;
|
||||
WND_PushCmd(window_frame, .kind = WND_CmdKind_SetCursorPos, .pos = prev_frame->screen_cursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame->screen_cursor = ui_frame->cursor_pos;
|
||||
}
|
||||
}
|
||||
frame->shade_cursor = MulAffineVec2(frame->af.screen_to_shade, frame->screen_cursor);
|
||||
frame->world_cursor = MulAffineVec2(frame->af.screen_to_world, frame->screen_cursor);
|
||||
|
||||
|
||||
@ -639,7 +639,6 @@ PixelShader(V_CompositePS, V_CompositePSOutput, V_CompositePSInput input)
|
||||
// TODO: Remove this
|
||||
|
||||
Vec4 crosshair_color = 0;
|
||||
if (frame.is_looking)
|
||||
{
|
||||
f32 dist = length(frame.screen_crosshair - screen_pos);
|
||||
if (dist < 4)
|
||||
|
||||
@ -36,6 +36,7 @@ Enum(WND_CmdKind)
|
||||
WND_CmdKind_SetFullscreen,
|
||||
WND_CmdKind_SetForcedTop,
|
||||
WND_CmdKind_SetCursor,
|
||||
WND_CmdKind_SetCursorPos,
|
||||
WND_CmdKind_SetLockedCursor,
|
||||
WND_CmdKind_Restore,
|
||||
};
|
||||
@ -46,6 +47,7 @@ Struct(WND_Cmd)
|
||||
WND_CursorKind cursor;
|
||||
String restore;
|
||||
b32 v;
|
||||
Vec2 pos;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@ -681,6 +681,14 @@ void WND_EndFrame(WND_Frame frame, i32 vsync)
|
||||
}
|
||||
} break;
|
||||
|
||||
//- Set cursor pos
|
||||
case WND_CmdKind_SetCursorPos:
|
||||
{
|
||||
POINT screen_pt = { cmd.pos.x, cmd.pos.y };
|
||||
ClientToScreen(hwnd, (LPPOINT)&screen_pt);
|
||||
SetCursorPos(screen_pt.x, screen_pt.y);
|
||||
} break;
|
||||
|
||||
//- Set locked cursor
|
||||
case WND_CmdKind_SetLockedCursor:
|
||||
{
|
||||
@ -747,7 +755,7 @@ void WND_EndFrame(WND_Frame frame, i32 vsync)
|
||||
BringWindowToTop(hwnd);
|
||||
}
|
||||
|
||||
// Set/Clip/Hide cursor
|
||||
// Set / Clip / Hide cursor
|
||||
{
|
||||
RECT virtual_screen_rect = Zi;
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user