Skip to content

Commit

Permalink
Fix mouse cursor visibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Jan 12, 2025
1 parent 80913b1 commit b2fdb35
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
5 changes: 2 additions & 3 deletions Patches/InputTweaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int32_t CanSave_Hook()

void DrawCursor_Hook()
{
if (HideMouseCursor || GetTransitionState() != FADE_NONE)
if (HideMouseCursor)
return;

orgDrawCursor.fun();
Expand Down Expand Up @@ -215,7 +215,6 @@ void UpdateMousePosition_Hook()
} // If cursor is not visible, and has moved from 0:0, set cursor to visible and restore its position
else if (HideMouseCursor && (GetMouseVerticalPosition() != 0 || GetMouseHorizontalPosition() != 0))
{

CursorPosHandler.RestoreCursorPos();

LastCursorXPos = GetMouseHorizontalPosition();
Expand Down Expand Up @@ -253,7 +252,7 @@ void UpdateMousePosition_Hook()
if (!(futureIndex == 0x01 && orgCanSave.fun() != 0x01))
{
#pragma warning(disable : 4244)
* GetPauseMenuButtonIndexPointer() = futureIndex;
*GetPauseMenuButtonIndexPointer() = futureIndex;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Resources/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 2224
#define BUILD_NUMBER 2225
7 changes: 4 additions & 3 deletions Wrappers/d3d8/IDirect3DDevice8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ HRESULT m_IDirect3DDevice8::DrawShadersAndScaledSurface()
ProxyInterface->GetRenderState(D3DRS_STENCILENABLE, &reStencilEnable);

// Get texture states
DWORD tsColorOP, tsColorArg1, tsColorArg2, tsAlphaOP, tsMinFilter, tsMagFilter, addressU[4], addressV[4];
DWORD tsColorOP, tsColorArg1, tsColorArg2, tsAlphaOP, tsMinFilter, tsMagFilter, addressU[4] = {}, addressV[4] = {};
ProxyInterface->GetTextureStageState(0, D3DTSS_COLOROP, &tsColorOP);
ProxyInterface->GetTextureStageState(0, D3DTSS_COLORARG1, &tsColorArg1);
ProxyInterface->GetTextureStageState(0, D3DTSS_COLORARG2, &tsColorArg2);
Expand Down Expand Up @@ -1706,6 +1706,7 @@ HRESULT m_IDirect3DDevice8::Present(CONST RECT* pSourceRect, CONST RECT* pDestRe
// Fix flashlight glitch in room 312
CheckRoom312Flashlight();

// Enable enhaced mouse cursor
if (EnableEnhancedMouse || EnhanceMouseCursor)
{
OverlayRef.RenderMouseCursor();
Expand Down Expand Up @@ -2733,8 +2734,8 @@ HRESULT m_IDirect3DDevice8::BeginScene()
RunPlayAdditionalSounds();
}

NeedToGrabScreenForWater = true;
RoachesDrawingCounter = 0;
NeedToGrabScreenForWater = true;
RoachesDrawingCounter = 0;
}

if (!isInScene)
Expand Down
18 changes: 16 additions & 2 deletions Wrappers/d3d8/Overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,24 @@ std::string Overlay::GetIGTString()

void Overlay::RenderMouseCursor()
{
if ((GetEventIndex() != EVENT_PAUSE_MENU && GetEventIndex() != EVENT_MEMO_LIST) || GetReadingMemoFlag() != 0 || GetTransitionState() != FADE_NONE)
static BYTE* pMousePointerVisibleFlagPointer = GetMousePointerVisibleFlagPointer();
if (pMousePointerVisibleFlagPointer)
{
if (GetTransitionState() != FADE_NONE)
{
*pMousePointerVisibleFlagPointer = 0;
}
else
{
*pMousePointerVisibleFlagPointer = 1;
}
}

if (!EnhanceMouseCursor || (GetEventIndex() != EVENT_PAUSE_MENU && GetEventIndex() != EVENT_MEMO_LIST) || GetReadingMemoFlag() != 0 || GetTransitionState() != FADE_NONE)
{
return;
}

*GetMousePointerVisibleFlagPointer() = 1;
SetShowCursorFlag_Hook();
DrawCursor_Hook();
}

0 comments on commit b2fdb35

Please sign in to comment.