Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions Minecraft.Client/Common/UI/UIController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "UIScene.h"
#include "UIControl_Slider.h"
#include "UIControl_TexturePackList.h"
#include "UIControl_CheckBox.h"
#include "../../../Minecraft.World/StringHelpers.h"
#include "../../LocalPlayer.h"
#include "../../DLCTexturePack.h"
Expand Down Expand Up @@ -791,6 +792,7 @@ void UIController::tickInput()
{
#ifdef _WINDOWS64
m_mouseClickConsumedByScene = false;
UIControl* currHitCtrl = NULL;
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
{
UIScene *pScene = nullptr;
Expand Down Expand Up @@ -955,7 +957,7 @@ void UIController::tickInput()
static_cast<S32>(sceneMouseX), static_cast<S32>(sceneMouseY), false);
hitControlId = -1;
hitArea = INT_MAX;
hitCtrl = NULL;
hitCtrl = ctrl;
break; // ButtonList takes priority
}
if (type == UIControl::eTexturePackList)
Expand All @@ -968,7 +970,7 @@ void UIController::tickInput()
m_bMouseHoverHorizontalList = true;
hitControlId = -1;
hitArea = INT_MAX;
hitCtrl = NULL;
hitCtrl = ctrl;
break;
}
S32 area = cw * ch;
Expand Down Expand Up @@ -1004,6 +1006,9 @@ void UIController::tickInput()
}
}
}

currHitCtrl = hitCtrl;
UpdateCursorIcon(currHitCtrl);
}
}

Expand Down Expand Up @@ -1127,6 +1132,27 @@ void UIController::tickInput()
}
}

void UIController::UpdateCursorIcon(UIControl *hitCtrl)
{
// Set cursor icon based on hovered UI element (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<UIControl_CheckBox *>(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
Expand Down Expand Up @@ -1995,6 +2021,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI
SetMenuDisplayed(menuDisplayedPad,true);
bool success = m_groups[static_cast<int>(group)]->NavigateToScene(iPad, scene, initData, layer);
if(success && group == eUIGroup_Fullscreen) setFullscreenMenuDisplayed(true);
UpdateCursorIcon(nullptr);
LeaveCriticalSection(&m_navigationLock);

timer.PrintElapsedTime(L"Navigate to scene");
Expand Down Expand Up @@ -2035,6 +2062,8 @@ bool UIController::NavigateBack(int iPad, bool forceUsePad, EUIScene eScene, EUI
if(!m_groups[static_cast<int>(eUIGroup_Fullscreen)]->GetMenuDisplayed()) SetMenuDisplayed(XUSER_INDEX_ANY,false);
}
return navComplete;

UpdateCursorIcon(nullptr);
}

void UIController::NavigateToHomeMenu()
Expand Down
1 change: 1 addition & 0 deletions Minecraft.Client/Common/UI/UIController.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class UIController : public IUIController
// INPUT
private:
void tickInput();
void UpdateCursorIcon(UIControl *hitCtrl);
void handleInput();
void handleKeyPress(unsigned int iPad, unsigned int key);

Expand Down
15 changes: 15 additions & 0 deletions Minecraft.Client/Windows64/KeyboardMouseInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,21 @@ float KeyboardMouseInput::GetLookY(float sensitivity) const
return static_cast<float>(-m_mouseDeltaY) * sensitivity;
}

void KeyboardMouseInput::SetCursorIcon(LPCWSTR cursorName)
{
HCURSOR hCursor = LoadCursorW(nullptr, cursorName);
if (hCursor)
{
SetCursor(hCursor);

if (g_hWnd)
{
// Update the cursor icon to keep the current one
SetClassLongPtrW(g_hWnd, GCLP_HCURSOR, (LONG_PTR)hCursor);
}
}
}

void KeyboardMouseInput::OnChar(wchar_t c)
{
int next = (m_charBufferHead + 1) % CHAR_BUFFER_SIZE;
Expand Down
2 changes: 2 additions & 0 deletions Minecraft.Client/Windows64/KeyboardMouseInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class KeyboardMouseInput
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];
Expand Down