aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyush Thoren <ayushthoren@gmail.com>2026-03-23 19:06:20 -0700
committerGitHub <noreply@github.com>2026-03-23 21:06:20 -0500
commited9cbae3f7cdcb8596b508f30075670e728655c6 (patch)
tree381a2212cb95003749288ea83bc70413698912e4
parentdaed75b8a18ebff56e89ca66c812f8db57f7635b (diff)
Fix initial cursor position for in-game UI elements (#1120)
Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
-rw-r--r--Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp2
-rw-r--r--Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.h10
-rw-r--r--Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp20
3 files changed, 8 insertions, 24 deletions
diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp
index fa9b280c..7db52b3f 100644
--- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp
+++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp
@@ -17,8 +17,6 @@
#ifdef _WINDOWS64
#include "..\..\Windows64\KeyboardMouseInput.h"
-
-SavedInventoryCursorPos g_savedInventoryCursorPos = { 0.0f, 0.0f, false };
#endif
IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu()
diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.h b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.h
index 718a2d44..6710e18f 100644
--- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.h
+++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.h
@@ -1,15 +1,5 @@
#pragma once
-#ifdef _WINDOWS64
-struct SavedInventoryCursorPos
-{
- float x;
- float y;
- bool hasSavedPos;
-};
-extern SavedInventoryCursorPos g_savedInventoryCursorPos;
-#endif
-
// Uncomment to enable tap input detection to jump 1 slot. Doesn't work particularly well yet, and I feel the system does not need it.
// Would probably be required if we decide to slow down the pointer movement.
// 4J Stu - There was a request to be able to navigate the scenes with the dpad, so I have used much of the TAP_DETECTION
diff --git a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
index 0c3b6096..c5dc0554 100644
--- a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
+++ b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
@@ -41,10 +41,6 @@ void UIScene_AbstractContainerMenu::handleDestroy()
app.DebugPrintf("UIScene_AbstractContainerMenu::handleDestroy\n");
#ifdef _WINDOWS64
- g_savedInventoryCursorPos.x = m_pointerPos.x;
- g_savedInventoryCursorPos.y = m_pointerPos.y;
- g_savedInventoryCursorPos.hasSavedPos = true;
-
g_KBMInput.SetScreenCursorHidden(false);
g_KBMInput.SetCursorHiddenForUI(false);
#endif
@@ -173,16 +169,16 @@ void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, int startIndex)
m_pointerPos = vPointerPos;
#ifdef _WINDOWS64
- if (g_savedInventoryCursorPos.hasSavedPos)
+ if ((iPad == 0) && g_KBMInput.IsKBMActive())
{
- m_pointerPos.x = g_savedInventoryCursorPos.x;
- m_pointerPos.y = g_savedInventoryCursorPos.y;
-
- if (m_pointerPos.x < m_fPointerMinX) m_pointerPos.x = m_fPointerMinX;
- if (m_pointerPos.x > m_fPointerMaxX) m_pointerPos.x = m_fPointerMaxX;
- if (m_pointerPos.y < m_fPointerMinY) m_pointerPos.y = m_fPointerMinY;
- if (m_pointerPos.y > m_fPointerMaxY) m_pointerPos.y = m_fPointerMaxY;
+ m_pointerPos.x = ((m_fPanelMinX + m_fPanelMaxX) * 0.5f) - m_fPointerImageOffsetX;
+ m_pointerPos.y = ((m_fPanelMinY + m_fPanelMaxY) * 0.5f) - m_fPointerImageOffsetY;
}
+
+ if (m_pointerPos.x < m_fPointerMinX) m_pointerPos.x = m_fPointerMinX;
+ if (m_pointerPos.x > m_fPointerMaxX) m_pointerPos.x = m_fPointerMaxX;
+ if (m_pointerPos.y < m_fPointerMinY) m_pointerPos.y = m_fPointerMinY;
+ if (m_pointerPos.y > m_fPointerMaxY) m_pointerPos.y = m_fPointerMaxY;
#endif
IggyEvent mouseEvent;