Fix Windows settings slider mouse input

This commit is contained in:
Merval 2026-05-08 14:13:13 -07:00
parent b132fd5fab
commit 565aaa55f6
5 changed files with 37 additions and 13 deletions

View file

@ -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()
{

View file

@ -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

View file

@ -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<UIControl *> *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; }

View file

@ -137,6 +137,7 @@ private:
bool m_navigateToHomeOnReload;
int m_accumulatedTicks;
int m_windowsMouseWheelForMenu;
bool m_windowsMouseSliderActive;
D3D11_RECT m_customRenderingClearRect;

View file

@ -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);