From 565aaa55f6c4331149b7e9366ef5c860280c36c0 Mon Sep 17 00:00:00 2001 From: Merval Date: Fri, 8 May 2026 14:13:13 -0700 Subject: [PATCH] Fix Windows settings slider mouse input --- Minecraft.Client/Common/UI/UIControl.cpp | 4 +-- Minecraft.Client/Common/UI/UIControl.h | 4 ++- Minecraft.Client/Common/UI/UIController.cpp | 26 ++++++++++++++----- Minecraft.Client/Common/UI/UIController.h | 1 + .../UI/UIScene_SettingsGraphicsMenu.cpp | 15 ++++++++--- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIControl.cpp b/Minecraft.Client/Common/UI/UIControl.cpp index a32485a..830dfa3 100644 --- a/Minecraft.Client/Common/UI/UIControl.cpp +++ b/Minecraft.Client/Common/UI/UIControl.cpp @@ -42,7 +42,7 @@ bool UIControl::setupControl(UIScene *scene, IggyValuePath *parent, const string return res; } -#ifdef __PSVITA__ +#if defined(__PSVITA__) || defined(_WINDOWS64) void UIControl::UpdateControl() { F64 fx, fy, fwidth, fheight; @@ -55,7 +55,7 @@ void UIControl::UpdateControl() m_width = (S32)Math::round(fwidth); m_height = (S32)Math::round(fheight); } -#endif // __PSVITA__ +#endif // __PSVITA__ || _WINDOWS64 void UIControl::ReInit() { diff --git a/Minecraft.Client/Common/UI/UIControl.h b/Minecraft.Client/Common/UI/UIControl.h index 3b4ef05..466c141 100644 --- a/Minecraft.Client/Common/UI/UIControl.h +++ b/Minecraft.Client/Common/UI/UIControl.h @@ -60,8 +60,10 @@ public: UIControl(); virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName); -#ifdef __PSVITA__ +#if defined(__PSVITA__) || defined(_WINDOWS64) void UpdateControl(); +#endif +#ifdef __PSVITA__ void setHidden(bool bHidden) {m_bHidden=bHidden;} bool getHidden(void) {return m_bHidden;} #endif diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 05afd4e..42e883d 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -217,6 +217,7 @@ UIController::UIController() m_winUserIndex = 0; m_accumulatedTicks = 0; m_windowsMouseWheelForMenu = 0; + m_windowsMouseSliderActive = false; InitializeCriticalSection(&m_navigationLock); InitializeCriticalSection(&m_registeredCallbackScenesCS); @@ -693,6 +694,7 @@ void UIController::tickInput() #endif { #ifdef _WINDOWS64 + m_windowsMouseSliderActive = false; if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive()) { UIScene *pScene = NULL; @@ -755,24 +757,36 @@ void UIController::tickInput() vector *controls = pScene->GetControls(); if (controls) { + S32 mainPanelOffsetX = 0; + S32 mainPanelOffsetY = 0; + UIControl *mainPanel = pScene->GetMainPanel(); + if (mainPanel) + { + mainPanel->UpdateControl(); + mainPanelOffsetX = mainPanel->getXPos(); + mainPanelOffsetY = mainPanel->getYPos(); + } + for (size_t i = 0; i < controls->size(); i++) { UIControl *ctrl = (*controls)[i]; if (ctrl && ctrl->getControlType() == UIControl::eSlider && ctrl->getVisible()) { - S32 cx = ctrl->getXPos(); - S32 cy = ctrl->getYPos(); - S32 cw = ctrl->getWidth(); + ctrl->UpdateControl(); + UIControl_Slider *pSlider = (UIControl_Slider *)ctrl; + S32 cx = ctrl->getXPos() + mainPanelOffsetX; + S32 cy = ctrl->getYPos() + mainPanelOffsetY; + S32 cw = pSlider->GetRealWidth(); S32 ch = ctrl->getHeight(); if (mouseX >= cx && mouseX <= cx + cw && mouseY >= cy && mouseY <= cy + ch) { - UIControl_Slider *pSlider = (UIControl_Slider *)ctrl; - float fNewSliderPos = (mouseX - (float)cx) / (float)pSlider->GetRealWidth(); + float fNewSliderPos = (mouseX - (float)cx) / (float)cw; if (fNewSliderPos < 0.0f) fNewSliderPos = 0.0f; if (fNewSliderPos > 1.0f) fNewSliderPos = 1.0f; pSlider->SetSliderTouchPos(fNewSliderPos); + m_windowsMouseSliderActive = true; break; } } @@ -1063,7 +1077,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) if (!pressed && !released && g_KBMInput.IsKeyDown(vk)) { down = true; } } - if (!keyboardTextEntryActive && (key == ACTION_MENU_OK || key == ACTION_MENU_A) && !g_KBMInput.IsMouseGrabbed()) + if (!keyboardTextEntryActive && (key == ACTION_MENU_OK || key == ACTION_MENU_A) && !g_KBMInput.IsMouseGrabbed() && !m_windowsMouseSliderActive) { if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)) { pressed = true; down = true; } if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) { released = true; down = false; } diff --git a/Minecraft.Client/Common/UI/UIController.h b/Minecraft.Client/Common/UI/UIController.h index 9bb130b..923cabe 100644 --- a/Minecraft.Client/Common/UI/UIController.h +++ b/Minecraft.Client/Common/UI/UIController.h @@ -137,6 +137,7 @@ private: bool m_navigateToHomeOnReload; int m_accumulatedTicks; int m_windowsMouseWheelForMenu; + bool m_windowsMouseSliderActive; D3D11_RECT m_customRenderingClearRect; diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp index 00a9426..e91036f 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp @@ -3,6 +3,13 @@ #include "UIScene_SettingsGraphicsMenu.h" #include "../../Minecraft.h" #include "../../GameRenderer.h" + +namespace +{ + const int FOV_MIN = 40; + const int FOV_MAX = 120; +} + UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { // Setup all the Iggy references we need for this scene @@ -28,7 +35,7 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD m_sliderInterfaceOpacity.init(TempString,eControl_InterfaceOpacity,0,100,app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity)); swprintf( (WCHAR *)TempString, 256, L"FOV: %d", (int)pMinecraft->gameRenderer->GetFovVal()); - m_sliderFov.init(TempString,eControl_FOV,40,120,(int)pMinecraft->gameRenderer->GetFovVal()); + m_sliderFov.init(TempString,eControl_FOV,0,FOV_MAX - FOV_MIN,(int)pMinecraft->gameRenderer->GetFovVal() - FOV_MIN); doHorizontalResizeCheck(); @@ -174,11 +181,11 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal break; case eControl_FOV: { - int fovValue = (int)currentValue; - m_sliderFov.handleSliderMove(fovValue); + int fovValue = (int)currentValue + FOV_MIN; + m_sliderFov.handleSliderMove((int)currentValue); Minecraft *pMinecraft = Minecraft::GetInstance(); - pMinecraft->gameRenderer->SetFovVal((float)currentValue); + pMinecraft->gameRenderer->SetFovVal((float)fovValue); WCHAR TempString[256]; swprintf( (WCHAR *)TempString, 256, L"FOV: %d", fovValue);