mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-08-14 08:32:30 +00:00
Fix Windows settings slider mouse input
This commit is contained in:
parent
b132fd5fab
commit
565aaa55f6
|
|
@ -42,7 +42,7 @@ bool UIControl::setupControl(UIScene *scene, IggyValuePath *parent, const string
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __PSVITA__
|
#if defined(__PSVITA__) || defined(_WINDOWS64)
|
||||||
void UIControl::UpdateControl()
|
void UIControl::UpdateControl()
|
||||||
{
|
{
|
||||||
F64 fx, fy, fwidth, fheight;
|
F64 fx, fy, fwidth, fheight;
|
||||||
|
|
@ -55,7 +55,7 @@ void UIControl::UpdateControl()
|
||||||
m_width = (S32)Math::round(fwidth);
|
m_width = (S32)Math::round(fwidth);
|
||||||
m_height = (S32)Math::round(fheight);
|
m_height = (S32)Math::round(fheight);
|
||||||
}
|
}
|
||||||
#endif // __PSVITA__
|
#endif // __PSVITA__ || _WINDOWS64
|
||||||
|
|
||||||
void UIControl::ReInit()
|
void UIControl::ReInit()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,10 @@ public:
|
||||||
UIControl();
|
UIControl();
|
||||||
|
|
||||||
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
|
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
|
||||||
#ifdef __PSVITA__
|
#if defined(__PSVITA__) || defined(_WINDOWS64)
|
||||||
void UpdateControl();
|
void UpdateControl();
|
||||||
|
#endif
|
||||||
|
#ifdef __PSVITA__
|
||||||
void setHidden(bool bHidden) {m_bHidden=bHidden;}
|
void setHidden(bool bHidden) {m_bHidden=bHidden;}
|
||||||
bool getHidden(void) {return m_bHidden;}
|
bool getHidden(void) {return m_bHidden;}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,7 @@ UIController::UIController()
|
||||||
m_winUserIndex = 0;
|
m_winUserIndex = 0;
|
||||||
m_accumulatedTicks = 0;
|
m_accumulatedTicks = 0;
|
||||||
m_windowsMouseWheelForMenu = 0;
|
m_windowsMouseWheelForMenu = 0;
|
||||||
|
m_windowsMouseSliderActive = false;
|
||||||
|
|
||||||
InitializeCriticalSection(&m_navigationLock);
|
InitializeCriticalSection(&m_navigationLock);
|
||||||
InitializeCriticalSection(&m_registeredCallbackScenesCS);
|
InitializeCriticalSection(&m_registeredCallbackScenesCS);
|
||||||
|
|
@ -693,6 +694,7 @@ void UIController::tickInput()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
|
m_windowsMouseSliderActive = false;
|
||||||
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||||
{
|
{
|
||||||
UIScene *pScene = NULL;
|
UIScene *pScene = NULL;
|
||||||
|
|
@ -755,24 +757,36 @@ void UIController::tickInput()
|
||||||
vector<UIControl *> *controls = pScene->GetControls();
|
vector<UIControl *> *controls = pScene->GetControls();
|
||||||
if (controls)
|
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++)
|
for (size_t i = 0; i < controls->size(); i++)
|
||||||
{
|
{
|
||||||
UIControl *ctrl = (*controls)[i];
|
UIControl *ctrl = (*controls)[i];
|
||||||
if (ctrl && ctrl->getControlType() == UIControl::eSlider && ctrl->getVisible())
|
if (ctrl && ctrl->getControlType() == UIControl::eSlider && ctrl->getVisible())
|
||||||
{
|
{
|
||||||
S32 cx = ctrl->getXPos();
|
ctrl->UpdateControl();
|
||||||
S32 cy = ctrl->getYPos();
|
UIControl_Slider *pSlider = (UIControl_Slider *)ctrl;
|
||||||
S32 cw = ctrl->getWidth();
|
S32 cx = ctrl->getXPos() + mainPanelOffsetX;
|
||||||
|
S32 cy = ctrl->getYPos() + mainPanelOffsetY;
|
||||||
|
S32 cw = pSlider->GetRealWidth();
|
||||||
S32 ch = ctrl->getHeight();
|
S32 ch = ctrl->getHeight();
|
||||||
|
|
||||||
if (mouseX >= cx && mouseX <= cx + cw &&
|
if (mouseX >= cx && mouseX <= cx + cw &&
|
||||||
mouseY >= cy && mouseY <= cy + ch)
|
mouseY >= cy && mouseY <= cy + ch)
|
||||||
{
|
{
|
||||||
UIControl_Slider *pSlider = (UIControl_Slider *)ctrl;
|
float fNewSliderPos = (mouseX - (float)cx) / (float)cw;
|
||||||
float fNewSliderPos = (mouseX - (float)cx) / (float)pSlider->GetRealWidth();
|
|
||||||
if (fNewSliderPos < 0.0f) fNewSliderPos = 0.0f;
|
if (fNewSliderPos < 0.0f) fNewSliderPos = 0.0f;
|
||||||
if (fNewSliderPos > 1.0f) fNewSliderPos = 1.0f;
|
if (fNewSliderPos > 1.0f) fNewSliderPos = 1.0f;
|
||||||
pSlider->SetSliderTouchPos(fNewSliderPos);
|
pSlider->SetSliderTouchPos(fNewSliderPos);
|
||||||
|
m_windowsMouseSliderActive = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1063,7 +1077,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
|
||||||
if (!pressed && !released && g_KBMInput.IsKeyDown(vk)) { down = true; }
|
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.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)) { pressed = true; down = true; }
|
||||||
if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) { released = true; down = false; }
|
if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) { released = true; down = false; }
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,7 @@ private:
|
||||||
bool m_navigateToHomeOnReload;
|
bool m_navigateToHomeOnReload;
|
||||||
int m_accumulatedTicks;
|
int m_accumulatedTicks;
|
||||||
int m_windowsMouseWheelForMenu;
|
int m_windowsMouseWheelForMenu;
|
||||||
|
bool m_windowsMouseSliderActive;
|
||||||
|
|
||||||
D3D11_RECT m_customRenderingClearRect;
|
D3D11_RECT m_customRenderingClearRect;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,13 @@
|
||||||
#include "UIScene_SettingsGraphicsMenu.h"
|
#include "UIScene_SettingsGraphicsMenu.h"
|
||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "../../GameRenderer.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)
|
UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
||||||
{
|
{
|
||||||
// Setup all the Iggy references we need for this scene
|
// 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));
|
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());
|
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();
|
doHorizontalResizeCheck();
|
||||||
|
|
||||||
|
|
@ -174,11 +181,11 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal
|
||||||
break;
|
break;
|
||||||
case eControl_FOV:
|
case eControl_FOV:
|
||||||
{
|
{
|
||||||
int fovValue = (int)currentValue;
|
int fovValue = (int)currentValue + FOV_MIN;
|
||||||
m_sliderFov.handleSliderMove(fovValue);
|
m_sliderFov.handleSliderMove((int)currentValue);
|
||||||
|
|
||||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||||
pMinecraft->gameRenderer->SetFovVal((float)currentValue);
|
pMinecraft->gameRenderer->SetFovVal((float)fovValue);
|
||||||
|
|
||||||
WCHAR TempString[256];
|
WCHAR TempString[256];
|
||||||
swprintf( (WCHAR *)TempString, 256, L"FOV: %d", fovValue);
|
swprintf( (WCHAR *)TempString, 256, L"FOV: %d", fovValue);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue