diff --git a/source/duke3d/src/events_defs.h b/source/duke3d/src/events_defs.h index 98bb89fb4..4cbc232f0 100644 --- a/source/duke3d/src/events_defs.h +++ b/source/duke3d/src/events_defs.h @@ -148,6 +148,7 @@ enum GameEvent_t { EVENT_MENUSHADESELECTED, EVENT_PLAYLEVELMUSICSLOT, EVENT_CONTINUELEVELMUSICSLOT, + EVENT_DISPLAYPOINTER, #ifdef LUNATIC EVENT_ANIMATEALLSPRITES, #endif diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 44bf764b6..8ecc807d9 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -764,6 +764,7 @@ const char *EventNames[MAXEVENTS] = "EVENT_MENUSHADESELECTED", "EVENT_PLAYLEVELMUSICSLOT", "EVENT_CONTINUELEVELMUSICSLOT", + "EVENT_DISPLAYPOINTER", #ifdef LUNATIC "EVENT_ANIMATEALLSPRITES", #endif diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 62ef917b4..617ed5efb 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -6765,6 +6765,12 @@ void M_DisplayMenus(void) // Display the mouse cursor, except on touch devices. if (MOUSEACTIVECONDITION) { + if (VM_HaveEvent(EVENT_DISPLAYCURSOR)) + { + ud.returnvar[0] = m_mousepos.x; + ud.returnvar[1] = m_mousepos.y; + ud.returnvar[2] = CURSORALPHA; + } int32_t a = VM_OnEventWithReturn(EVENT_DISPLAYCURSOR, g_player[screenpeek].ps->i, screenpeek, CROSSHAIR); if ((unsigned) a < MAXTILES) @@ -6780,7 +6786,7 @@ void M_DisplayMenus(void) setaspect(viewingrange, 65536); cursorpos.x = scale(cursorpos.x - (320<<15), ydim << 2, xdim * 3) + (320<<15); cursorpos.y = scale(cursorpos.y - (200<<15), (ydim << 2) * 6, (xdim * 3) * 5) + (200<<15); - z = scale(65536, ydim << 2, xdim * 3); + z = scale(z, ydim << 2, xdim * 3); p = 0; o |= 1024; } diff --git a/source/duke3d/src/menus.h b/source/duke3d/src/menus.h index 84d010724..b47bbf754 100644 --- a/source/duke3d/src/menus.h +++ b/source/duke3d/src/menus.h @@ -479,7 +479,7 @@ extern int32_t m_mousewake_watchpoint, m_menuchange_watchpoint; // use 16 anyway :P # define MOUSEUSEALPHA (getrendermode() != REND_CLASSIC || numalphatabs >= 15) # define MOUSEALPHA (MOUSEUSEALPHA ? clamp((totalclock - m_mouselastactivity - 90)*3, 0, 255) : 0) -# define CURSORALPHA (MOUSEUSEALPHA ? clamp((totalclock - m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 0) +# define CURSORALPHA (MOUSEUSEALPHA ? clamp((totalclock - m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3) # define MOUSEACTIVECONDITION (totalclock - m_mouselastactivity < M_MOUSETIMEOUT) # define MOUSEACTIVECONDITIONAL(condition) (MOUSEACTIVECONDITION && (condition)) # define MOUSEINACTIVECONDITIONAL(condition) (!MOUSEACTIVECONDITION && (condition)) diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 5a8e694a3..36fdfc74d 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -1156,25 +1156,21 @@ void G_DisplayRest(int32_t smoothratio) if (g_player[myconnectindex].ps->newowner == -1 && ud.overhead_on == 0 && ud.crosshair && ud.camerasprite == -1) { - int32_t a = VM_OnEvent(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek); - + ud.returnvar[0] = (160<<16) - (g_player[myconnectindex].ps->look_ang<<15); + ud.returnvar[1] = 100<<16; + int32_t a = VM_OnEventWithReturn(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek, CROSSHAIR); if ((unsigned) a < MAXTILES) { - if (a == 0) - a = CROSSHAIR; - - vec2_t crosshairpos = { (160<<16) - (g_player[myconnectindex].ps->look_ang<<15), 100<<16 }; - + vec2_t crosshairpos = { ud.returnvar[0], ud.returnvar[1] }; uint8_t crosshair_pal = CROSSHAIR_PAL; uint32_t crosshair_o = 1|2; uint32_t crosshair_scale = divscale16(ud.crosshairscale, 100); auto const oyxaspect = yxaspect; - if (KXDWN) { crosshairpos.x = scale(crosshairpos.x - (320<<15), ydim << 2, xdim * 3) + (320<<15); - // crosshairpos.y = scale(crosshairpos.y - (200<<15), (ydim << 2) * 6, (xdim * 3) * 5) + (200<<15); // no-op for constant centering + crosshairpos.y = scale(crosshairpos.y - (200<<15), (ydim << 2) * 6, (xdim * 3) * 5) + (200<<15); crosshair_scale = scale(crosshair_scale, ydim << 2, xdim * 3) >> 1; crosshair_pal = 0; crosshair_o |= 1024; @@ -1183,19 +1179,42 @@ void G_DisplayRest(int32_t smoothratio) rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, crosshair_pal, crosshair_o); + if (KXDWN) + setaspect(viewingrange, oyxaspect); + } + } + #ifdef GEKKO - if ((g_player[myconnectindex].ps->gm&MODE_MENU) == 0 && readmouseabsxy(&crosshairpos, &mouseabs)) + // like the mouse cursor, the pointer doesn't use the crosshair enabled / scale options + if (g_player[myconnectindex].ps->newowner == -1 && ud.overhead_on == 0 && ud.camerasprite == -1 && + (g_player[myconnectindex].ps->gm&MODE_MENU) == 0 && readmouseabsxy((vec2_t *)&ud.returnvar[0], &mouseabs)) + { + int32_t a = VM_OnEventWithReturn(EVENT_DISPLAYPOINTER, g_player[screenpeek].ps->i, screenpeek, CROSSHAIR); + if ((unsigned) a < MAXTILES) + { + vec2_t pointerpos = { ud.returnvar[0], ud.returnvar[1] }; + uint8_t pointer_pal = CROSSHAIR_PAL; + uint32_t pointer_o = 1|2; + uint32_t pointer_scale = 65536; + + auto const oyxaspect = yxaspect; + if (KXDWN) { - crosshairpos.x = scale(crosshairpos.x - (320<<15), ydim << 2, xdim * 3) + (320<<15); - crosshairpos.y = scale(crosshairpos.y - (200<<15), (ydim << 2) * 6, (xdim * 3) * 5) + (200<<15); - rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, crosshair_pal, crosshair_o); + pointerpos.x = scale(pointerpos.x - (320<<15), ydim << 2, xdim * 3) + (320<<15); + pointerpos.y = scale(pointerpos.y - (200<<15), (ydim << 2) * 6, (xdim * 3) * 5) + (200<<15); + pointer_scale = scale(pointer_scale, ydim << 2, xdim * 3) >> 1; + pointer_pal = 0; + pointer_o |= 1024; + setaspect(viewingrange, 65536); } -#endif + + rotatesprite_win(pointerpos.x, pointerpos.y, pointer_scale, 0, a, 0, pointer_pal, pointer_o); if (KXDWN) setaspect(viewingrange, oyxaspect); } } +#endif #if 0 if (g_gametypeFlags[ud.coop] & GAMETYPE_TDM) {