diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 86161e97..04976b5b 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -5,6 +5,7 @@ #include "UIScene.h" #include "UIControl_Slider.h" #include "UIControl_TexturePackList.h" +#include "UIControl_CheckBox.h" #include "UIControl_AchievementsList.h" #include "UIScene_AchievementsMenu.h" #include "../../../Minecraft.World/StringHelpers.h" @@ -836,6 +837,7 @@ void UIController::tickInput() { #ifdef _WINDOWS64 m_mouseClickConsumedByScene = false; + UIControl* currHitCtrl = NULL; if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive()) { UIScene *pScene = nullptr; @@ -1010,6 +1012,7 @@ void UIController::tickInput() hitControlId = -1; hitArea = INT_MAX; hitCtrl = NULL; + hitCtrl = ctrl; break; // ButtonList takes priority } if (type == UIControl::eAchievementList) @@ -1022,6 +1025,7 @@ void UIController::tickInput() hitControlId = -1; hitArea = INT_MAX; hitCtrl = NULL; + hitCtrl = ctrl; break; } if (type == UIControl::eTexturePackList) @@ -1070,6 +1074,8 @@ void UIController::tickInput() } } } + currHitCtrl = hitCtrl; + UpdateCursorIcon(currHitCtrl); } } @@ -1196,6 +1202,27 @@ void UIController::tickInput() } } +void UIController::UpdateCursorIcon(UIControl *hitCtrl) +{ + // from WinUser.h + if (hitCtrl && (hitCtrl->getControlType() == UIControl::eButton || hitCtrl->getControlType() == UIControl::eButtonList)) + g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND)); + else if (hitCtrl && (hitCtrl->getControlType() == UIControl::eSlider || hitCtrl->getControlType() == UIControl::eTexturePackList)) + g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_SIZEWE)); + else if (hitCtrl && hitCtrl->getControlType() == UIControl::eTextInput) + g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_IBEAM)); + else if (hitCtrl && hitCtrl->getControlType() == UIControl::eCheckBox) // Show the cross sign shaped cursor only when the checkbox is disabled/grayed out + { + UIControl_CheckBox *pCheck = static_cast(hitCtrl); + if (pCheck && !pCheck->IsEnabled()) + g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_NO)); + else + g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_HAND)); + } + else + g_KBMInput.SetCursorIcon(MAKEINTRESOURCEW(IDC_ARROW)); +} + void UIController::handleInput() { // For each user, loop over each key type and send messages based on the state @@ -2078,6 +2105,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI SetMenuDisplayed(menuDisplayedPad,true); bool success = m_groups[static_cast(group)]->NavigateToScene(iPad, scene, initData, layer); if(success && group == eUIGroup_Fullscreen) setFullscreenMenuDisplayed(true); + UpdateCursorIcon(nullptr); LeaveCriticalSection(&m_navigationLock); timer.PrintElapsedTime(L"Navigate to scene"); @@ -2117,6 +2145,7 @@ bool UIController::NavigateBack(int iPad, bool forceUsePad, EUIScene eScene, EUI navComplete = m_groups[static_cast(eUIGroup_Fullscreen)]->NavigateBack(iPad, eScene, eLayer); if(!m_groups[static_cast(eUIGroup_Fullscreen)]->GetMenuDisplayed()) SetMenuDisplayed(XUSER_INDEX_ANY,false); } + UpdateCursorIcon(nullptr); return navComplete; } diff --git a/Minecraft.Client/Common/UI/UIController.h b/Minecraft.Client/Common/UI/UIController.h index 776de903..27c5c61d 100644 --- a/Minecraft.Client/Common/UI/UIController.h +++ b/Minecraft.Client/Common/UI/UIController.h @@ -262,6 +262,7 @@ public: // INPUT private: void tickInput(); + void UpdateCursorIcon(UIControl *hitCtrl); void handleInput(); void handleKeyPress(unsigned int iPad, unsigned int key); diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp index be6efe90..3b6f5aec 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp @@ -390,6 +390,20 @@ float KeyboardMouseInput::GetLookY(float sensitivity) const return static_cast(-m_mouseDeltaY) * sensitivity; } +void KeyboardMouseInput::SetCursorIcon(LPCWSTR cursorName) +{ + HCURSOR hCursor = LoadCursorW(nullptr, cursorName); + if (hCursor) + { + SetCursor(hCursor); + + if (g_hWnd) + { + SetClassLongPtrW(g_hWnd, GCLP_HCURSOR, (LONG_PTR)hCursor); + } + } +} + void KeyboardMouseInput::OnChar(wchar_t c) { int next = (m_charBufferHead + 1) % CHAR_BUFFER_SIZE; diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.h b/Minecraft.Client/Windows64/KeyboardMouseInput.h index 23158ed2..ed98a03c 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.h +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.h @@ -104,6 +104,8 @@ public: float GetLookX(float sensitivity) const; float GetLookY(float sensitivity) const; + void SetCursorIcon(LPCWSTR cursorName); + private: bool m_keyDown[MAX_KEYS]; bool m_keyDownPrev[MAX_KEYS];