refactor: refactor KBM input code
This commit is contained in:
@@ -13,6 +13,12 @@
|
||||
#include <pad.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include "..\..\Windows64\KeyboardMouseInput.h"
|
||||
|
||||
SavedInventoryCursorPos g_savedInventoryCursorPos = { 0.0f, 0.0f, false };
|
||||
#endif
|
||||
|
||||
IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu()
|
||||
{
|
||||
m_menu = NULL;
|
||||
@@ -474,6 +480,34 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
int deltaX = g_KBMInput.GetMouseDeltaX();
|
||||
int deltaY = g_KBMInput.GetMouseDeltaY();
|
||||
|
||||
extern HWND g_hWnd;
|
||||
RECT rc;
|
||||
GetClientRect(g_hWnd, &rc);
|
||||
int winW = rc.right - rc.left;
|
||||
int winH = rc.bottom - rc.top;
|
||||
|
||||
if (winW > 0 && winH > 0)
|
||||
{
|
||||
float scaleX = (float)getMovieWidth() / (float)winW;
|
||||
float scaleY = (float)getMovieHeight() / (float)winH;
|
||||
|
||||
vPointerPos.x += (float)deltaX * scaleX;
|
||||
vPointerPos.y += (float)deltaY * scaleY;
|
||||
}
|
||||
|
||||
if (deltaX != 0 || deltaY != 0)
|
||||
{
|
||||
bStickInput = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Determine which slot the pointer is currently over.
|
||||
ESceneSection eSectionUnderPointer = eSectionNone;
|
||||
int iNewSlotX = -1;
|
||||
@@ -694,7 +728,11 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
|
||||
|
||||
// If there is no stick input, and we are over a slot, then snap pointer to slot centre.
|
||||
// 4J - TomK - only if this particular component allows so!
|
||||
if(!m_bPointerDrivenByMouse && CanHaveFocus(eSectionUnderPointer))
|
||||
#ifdef _WINDOWS64
|
||||
if((g_KBMInput.IsMouseGrabbed() || !g_KBMInput.IsKBMActive()) && CanHaveFocus(eSectionUnderPointer))
|
||||
#else
|
||||
if(CanHaveFocus(eSectionUnderPointer))
|
||||
#endif
|
||||
{
|
||||
vPointerPos.x = vSnapPos.x;
|
||||
vPointerPos.y = vSnapPos.y;
|
||||
@@ -1329,7 +1367,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b
|
||||
|
||||
// Standard left click
|
||||
buttonNum = 0;
|
||||
if (KMInput.IsKeyDown(VK_SHIFT))
|
||||
if (g_KBMInput.IsKeyDown(VK_LSHIFT))
|
||||
{
|
||||
{
|
||||
validKeyPress = TRUE;
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
struct SavedInventoryCursorPos
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
bool hasSavedPos;
|
||||
};
|
||||
extern SavedInventoryCursorPos g_savedInventoryCursorPos;
|
||||
#endif
|
||||
|
||||
// Uncomment to enable tap input detection to jump 1 slot. Doesn't work particularly well yet, and I feel the system does not need it.
|
||||
// Would probably be required if we decide to slow down the pointer movement.
|
||||
// 4J Stu - There was a request to be able to navigate the scenes with the dpad, so I have used much of the TAP_DETECTION
|
||||
@@ -265,4 +275,6 @@ protected:
|
||||
|
||||
public:
|
||||
virtual int getPad() = 0;
|
||||
virtual int getMovieWidth() = 0;
|
||||
virtual int getMovieHeight() = 0;
|
||||
};
|
||||
|
||||
@@ -42,7 +42,6 @@ bool UIControl::setupControl(UIScene *scene, IggyValuePath *parent, const string
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef __PSVITA__
|
||||
void UIControl::UpdateControl()
|
||||
{
|
||||
F64 fx, fy, fwidth, fheight;
|
||||
@@ -55,7 +54,6 @@ void UIControl::UpdateControl()
|
||||
m_width = (S32)Math::round(fwidth);
|
||||
m_height = (S32)Math::round(fheight);
|
||||
}
|
||||
#endif // __PSVITA__
|
||||
|
||||
void UIControl::ReInit()
|
||||
{
|
||||
|
||||
@@ -61,8 +61,8 @@ public:
|
||||
UIControl();
|
||||
|
||||
virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName);
|
||||
#ifdef __PSVITA__
|
||||
void UpdateControl();
|
||||
#ifdef __PSVITA__
|
||||
void setHidden(bool bHidden) {m_bHidden=bHidden;}
|
||||
bool getHidden(void) {return m_bHidden;}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "UIController.h"
|
||||
#include "UI.h"
|
||||
#include "UIScene.h"
|
||||
#include "UIControl_Slider.h"
|
||||
#include "..\..\..\Minecraft.World\StringHelpers.h"
|
||||
#include "..\..\LocalPlayer.h"
|
||||
#include "..\..\DLCTexturePack.h"
|
||||
@@ -11,6 +12,9 @@
|
||||
#include "..\..\EnderDragonRenderer.h"
|
||||
#include "..\..\MultiPlayerLocalPlayer.h"
|
||||
#include "UIFontData.h"
|
||||
#ifdef _WINDOWS64
|
||||
#include "..\..\Windows64\KeyboardMouseInput.h"
|
||||
#endif
|
||||
#ifdef __PSVITA__
|
||||
#include <message_dialog.h>
|
||||
#endif
|
||||
@@ -52,6 +56,21 @@ bool UIController::ms_bReloadSkinCSInitialised = false;
|
||||
|
||||
DWORD UIController::m_dwTrialTimerLimitSecs=DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME;
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
static UIControl_Slider *FindSliderById(UIScene *pScene, int sliderId)
|
||||
{
|
||||
vector<UIControl *> *controls = pScene->GetControls();
|
||||
if (!controls) return NULL;
|
||||
for (size_t i = 0; i < controls->size(); ++i)
|
||||
{
|
||||
UIControl *ctrl = (*controls)[i];
|
||||
if (ctrl && ctrl->getControlType() == UIControl::eSlider && ctrl->getId() == sliderId)
|
||||
return (UIControl_Slider *)ctrl;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void RADLINK WarningCallback(void *user_callback_data, Iggy *player, IggyResult code, const char *message)
|
||||
{
|
||||
//enum IggyResult{ IGGY_RESULT_SUCCESS = 0, IGGY_RESULT_Warning_None = 0,
|
||||
@@ -216,6 +235,10 @@ UIController::UIController()
|
||||
m_currentRenderViewport = C4JRender::VIEWPORT_TYPE_FULLSCREEN;
|
||||
m_bCustomRenderPosition = false;
|
||||
m_winUserIndex = 0;
|
||||
m_mouseDraggingSliderScene = eUIScene_COUNT;
|
||||
m_mouseDraggingSliderId = -1;
|
||||
m_lastHoverMouseX = -1;
|
||||
m_lastHoverMouseY = -1;
|
||||
m_accumulatedTicks = 0;
|
||||
m_lastUiSfx = 0;
|
||||
|
||||
@@ -761,6 +784,168 @@ void UIController::tickInput()
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
UIScene *pScene = NULL;
|
||||
for (int grp = 0; grp < eUIGroup_COUNT && !pScene; ++grp)
|
||||
{
|
||||
pScene = m_groups[grp]->GetTopScene(eUILayer_Debug);
|
||||
if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Tooltips);
|
||||
if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Error);
|
||||
if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Alert);
|
||||
if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Popup);
|
||||
if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Fullscreen);
|
||||
if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Scene);
|
||||
}
|
||||
if (pScene && pScene->getMovie())
|
||||
{
|
||||
Iggy *movie = pScene->getMovie();
|
||||
int rawMouseX = g_KBMInput.GetMouseX();
|
||||
int rawMouseY = g_KBMInput.GetMouseY();
|
||||
F32 mouseX = (F32)rawMouseX;
|
||||
F32 mouseY = (F32)rawMouseY;
|
||||
|
||||
extern HWND g_hWnd;
|
||||
if (g_hWnd)
|
||||
{
|
||||
RECT rc;
|
||||
GetClientRect(g_hWnd, &rc);
|
||||
int winW = rc.right - rc.left;
|
||||
int winH = rc.bottom - rc.top;
|
||||
if (winW > 0 && winH > 0)
|
||||
{
|
||||
mouseX = mouseX * (m_fScreenWidth / (F32)winW);
|
||||
mouseY = mouseY * (m_fScreenHeight / (F32)winH);
|
||||
}
|
||||
}
|
||||
|
||||
// Only update hover focus when the mouse has actually moved,
|
||||
// so that mouse-wheel scrolling can change list selection
|
||||
// without the hover immediately snapping focus back.
|
||||
bool mouseMoved = (rawMouseX != m_lastHoverMouseX || rawMouseY != m_lastHoverMouseY);
|
||||
m_lastHoverMouseX = rawMouseX;
|
||||
m_lastHoverMouseY = rawMouseY;
|
||||
|
||||
if (mouseMoved)
|
||||
{
|
||||
IggyFocusHandle currentFocus = IGGY_FOCUS_NULL;
|
||||
IggyFocusableObject focusables[64];
|
||||
S32 numFocusables = 0;
|
||||
IggyPlayerGetFocusableObjects(movie, ¤tFocus, focusables, 64, &numFocusables);
|
||||
|
||||
if (numFocusables > 0 && numFocusables <= 64)
|
||||
{
|
||||
IggyFocusHandle hitObject = IGGY_FOCUS_NULL;
|
||||
for (S32 i = 0; i < numFocusables; ++i)
|
||||
{
|
||||
if (mouseX >= focusables[i].x0 && mouseX <= focusables[i].x1 &&
|
||||
mouseY >= focusables[i].y0 && mouseY <= focusables[i].y1)
|
||||
{
|
||||
hitObject = focusables[i].object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hitObject != currentFocus)
|
||||
{
|
||||
IggyPlayerSetFocusRS(movie, hitObject, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert mouse to scene/movie coordinates for slider hit testing
|
||||
F32 sceneMouseX = mouseX;
|
||||
F32 sceneMouseY = mouseY;
|
||||
{
|
||||
S32 displayWidth = 0, displayHeight = 0;
|
||||
pScene->GetParentLayer()->getRenderDimensions(displayWidth, displayHeight);
|
||||
if (displayWidth > 0 && displayHeight > 0)
|
||||
{
|
||||
sceneMouseX = mouseX * ((F32)pScene->getRenderWidth() / (F32)displayWidth);
|
||||
sceneMouseY = mouseY * ((F32)pScene->getRenderHeight() / (F32)displayHeight);
|
||||
}
|
||||
}
|
||||
|
||||
// Get main panel offset (controls are positioned relative to it)
|
||||
S32 panelOffsetX = 0, panelOffsetY = 0;
|
||||
UIControl *pMainPanel = pScene->GetMainPanel();
|
||||
if (pMainPanel)
|
||||
{
|
||||
pMainPanel->UpdateControl();
|
||||
panelOffsetX = pMainPanel->getXPos();
|
||||
panelOffsetY = pMainPanel->getYPos();
|
||||
}
|
||||
|
||||
bool leftPressed = g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT);
|
||||
bool leftDown = leftPressed || g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT);
|
||||
|
||||
if (m_mouseDraggingSliderScene != eUIScene_COUNT && m_mouseDraggingSliderScene != pScene->getSceneType())
|
||||
{
|
||||
m_mouseDraggingSliderScene = eUIScene_COUNT;
|
||||
m_mouseDraggingSliderId = -1;
|
||||
}
|
||||
|
||||
if (leftPressed)
|
||||
{
|
||||
vector<UIControl *> *controls = pScene->GetControls();
|
||||
if (controls)
|
||||
{
|
||||
for (size_t i = 0; i < controls->size(); ++i)
|
||||
{
|
||||
UIControl *ctrl = (*controls)[i];
|
||||
if (!ctrl || ctrl->getControlType() != UIControl::eSlider || !ctrl->getVisible())
|
||||
continue;
|
||||
|
||||
UIControl_Slider *pSlider = (UIControl_Slider *)ctrl;
|
||||
pSlider->UpdateControl();
|
||||
S32 cx = pSlider->getXPos() + panelOffsetX;
|
||||
S32 cy = pSlider->getYPos() + panelOffsetY;
|
||||
S32 cw = pSlider->GetRealWidth();
|
||||
S32 ch = pSlider->getHeight();
|
||||
if (cw <= 0 || ch <= 0)
|
||||
continue;
|
||||
|
||||
if (sceneMouseX >= cx && sceneMouseX <= cx + cw && sceneMouseY >= cy && sceneMouseY <= cy + ch)
|
||||
{
|
||||
m_mouseDraggingSliderScene = pScene->getSceneType();
|
||||
m_mouseDraggingSliderId = pSlider->getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (leftDown && m_mouseDraggingSliderScene == pScene->getSceneType() && m_mouseDraggingSliderId >= 0)
|
||||
{
|
||||
UIControl_Slider *pSlider = FindSliderById(pScene, m_mouseDraggingSliderId);
|
||||
if (pSlider && pSlider->getVisible())
|
||||
{
|
||||
pSlider->UpdateControl();
|
||||
S32 sliderX = pSlider->getXPos() + panelOffsetX;
|
||||
S32 sliderWidth = pSlider->GetRealWidth();
|
||||
if (sliderWidth > 0)
|
||||
{
|
||||
float fNewSliderPos = (sceneMouseX - (float)sliderX) / (float)sliderWidth;
|
||||
if (fNewSliderPos < 0.0f) fNewSliderPos = 0.0f;
|
||||
if (fNewSliderPos > 1.0f) fNewSliderPos = 1.0f;
|
||||
pSlider->SetSliderTouchPos(fNewSliderPos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mouseDraggingSliderScene = eUIScene_COUNT;
|
||||
m_mouseDraggingSliderId = -1;
|
||||
}
|
||||
}
|
||||
else if (!leftDown)
|
||||
{
|
||||
m_mouseDraggingSliderScene = eUIScene_COUNT;
|
||||
m_mouseDraggingSliderId = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
handleInput();
|
||||
++m_accumulatedTicks;
|
||||
}
|
||||
@@ -995,28 +1180,59 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
|
||||
released = InputManager.ButtonReleased(iPad,key); // Toggle
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
// Keyboard menu input for player 0
|
||||
if (iPad == 0)
|
||||
{
|
||||
bool kbDown = false, kbPressed = false, kbReleased = false;
|
||||
switch(key)
|
||||
int vk = 0;
|
||||
switch (key)
|
||||
{
|
||||
case ACTION_MENU_UP: kbDown = KMInput.IsKeyDown(VK_UP); kbPressed = KMInput.IsKeyPressed(VK_UP); kbReleased = KMInput.IsKeyReleased(VK_UP); break;
|
||||
case ACTION_MENU_DOWN: kbDown = KMInput.IsKeyDown(VK_DOWN); kbPressed = KMInput.IsKeyPressed(VK_DOWN); kbReleased = KMInput.IsKeyReleased(VK_DOWN); break;
|
||||
case ACTION_MENU_LEFT: kbDown = KMInput.IsKeyDown(VK_LEFT); kbPressed = KMInput.IsKeyPressed(VK_LEFT); kbReleased = KMInput.IsKeyReleased(VK_LEFT); break;
|
||||
case ACTION_MENU_RIGHT: kbDown = KMInput.IsKeyDown(VK_RIGHT); kbPressed = KMInput.IsKeyPressed(VK_RIGHT); kbReleased = KMInput.IsKeyReleased(VK_RIGHT); break;
|
||||
case ACTION_MENU_OK: kbDown = KMInput.IsKeyDown(VK_RETURN); kbPressed = KMInput.IsKeyPressed(VK_RETURN); kbReleased = KMInput.IsKeyReleased(VK_RETURN); break;
|
||||
case ACTION_MENU_A: kbDown = KMInput.IsKeyDown(VK_RETURN); kbPressed = KMInput.IsKeyPressed(VK_RETURN); kbReleased = KMInput.IsKeyReleased(VK_RETURN); break;
|
||||
case ACTION_MENU_CANCEL: kbDown = KMInput.IsKeyDown(VK_ESCAPE); kbPressed = KMInput.IsKeyPressed(VK_ESCAPE); kbReleased = KMInput.IsKeyReleased(VK_ESCAPE); break;
|
||||
case ACTION_MENU_B: kbDown = KMInput.IsKeyDown(VK_ESCAPE); kbPressed = KMInput.IsKeyPressed(VK_ESCAPE); kbReleased = KMInput.IsKeyReleased(VK_ESCAPE); break;
|
||||
case ACTION_MENU_PAUSEMENU: kbDown = KMInput.IsKeyDown(VK_ESCAPE); kbPressed = KMInput.IsKeyPressed(VK_ESCAPE); kbReleased = KMInput.IsKeyReleased(VK_ESCAPE); break;
|
||||
case ACTION_MENU_LEFT_SCROLL: kbDown = KMInput.IsKeyDown('Q'); kbPressed = KMInput.IsKeyPressed('Q'); kbReleased = KMInput.IsKeyReleased('Q'); break;
|
||||
case ACTION_MENU_RIGHT_SCROLL: kbDown = KMInput.IsKeyDown('E'); kbPressed = KMInput.IsKeyPressed('E'); kbReleased = KMInput.IsKeyReleased('E'); break;
|
||||
case ACTION_MENU_QUICK_MOVE: kbDown = KMInput.IsKeyDown(VK_SHIFT); kbPressed = KMInput.IsKeyPressed(VK_SHIFT); kbReleased = KMInput.IsKeyReleased(VK_SHIFT); break;
|
||||
case ACTION_MENU_OK: case ACTION_MENU_A: vk = VK_RETURN; break;
|
||||
case ACTION_MENU_CANCEL: case ACTION_MENU_B: vk = VK_ESCAPE; break;
|
||||
case ACTION_MENU_UP: vk = VK_UP; break;
|
||||
case ACTION_MENU_DOWN: vk = VK_DOWN; break;
|
||||
case ACTION_MENU_LEFT: vk = VK_LEFT; break;
|
||||
case ACTION_MENU_RIGHT: vk = VK_RIGHT; break;
|
||||
case ACTION_MENU_X: vk = 'R'; break;
|
||||
case ACTION_MENU_Y: vk = VK_TAB; break;
|
||||
case ACTION_MENU_LEFT_SCROLL: vk = 'Q'; break;
|
||||
case ACTION_MENU_RIGHT_SCROLL: vk = 'E'; break;
|
||||
case ACTION_MENU_PAGEUP: vk = VK_PRIOR; break;
|
||||
case ACTION_MENU_PAGEDOWN: vk = VK_NEXT; break;
|
||||
}
|
||||
if (vk != 0)
|
||||
{
|
||||
if (g_KBMInput.IsKeyPressed(vk)) { pressed = true; down = true; }
|
||||
if (g_KBMInput.IsKeyReleased(vk)) { released = true; down = false; }
|
||||
if (!pressed && !released && g_KBMInput.IsKeyDown(vk)) { down = true; }
|
||||
}
|
||||
|
||||
if ((key == ACTION_MENU_OK || key == ACTION_MENU_A) && !g_KBMInput.IsMouseGrabbed())
|
||||
{
|
||||
if (m_mouseDraggingSliderId < 0)
|
||||
{
|
||||
if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)) { pressed = true; down = true; }
|
||||
if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) { released = true; down = false; }
|
||||
if (!pressed && !released && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT)) { down = true; }
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll wheel for list scrolling — only consume the wheel value when the
|
||||
// action key actually matches, so the other direction isn't lost.
|
||||
if (!g_KBMInput.IsMouseGrabbed() && (key == ACTION_MENU_OTHER_STICK_UP || key == ACTION_MENU_OTHER_STICK_DOWN))
|
||||
{
|
||||
int wheel = g_KBMInput.PeekMouseWheel();
|
||||
if (key == ACTION_MENU_OTHER_STICK_UP && wheel > 0)
|
||||
{
|
||||
g_KBMInput.ConsumeMouseWheel();
|
||||
pressed = true;
|
||||
down = true;
|
||||
}
|
||||
else if (key == ACTION_MENU_OTHER_STICK_DOWN && wheel < 0)
|
||||
{
|
||||
g_KBMInput.ConsumeMouseWheel();
|
||||
pressed = true;
|
||||
down = true;
|
||||
}
|
||||
}
|
||||
pressed = pressed || kbPressed;
|
||||
released = released || kbReleased;
|
||||
down = down || kbDown;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3138,4 +3354,4 @@ void UIController::SendTouchInput(unsigned int iPad, unsigned int key, bool bPre
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -158,6 +158,10 @@ private:
|
||||
vector<QueuedMessageBoxData *> m_queuedMessageBoxData;
|
||||
|
||||
unsigned int m_winUserIndex;
|
||||
EUIScene m_mouseDraggingSliderScene;
|
||||
int m_mouseDraggingSliderId;
|
||||
int m_lastHoverMouseX;
|
||||
int m_lastHoverMouseY;
|
||||
//bool m_bSysUIShowing;
|
||||
bool m_bSystemUIShowing;
|
||||
C4JThread *m_reloadSkinThread;
|
||||
|
||||
@@ -37,9 +37,7 @@ private:
|
||||
public:
|
||||
UIGroup(EUIGroup group, int iPad);
|
||||
|
||||
#ifdef __PSVITA__
|
||||
EUIGroup GetGroup() {return m_group;}
|
||||
#endif
|
||||
UIComponent_Tooltips *getTooltips() { return m_tooltips; }
|
||||
UIComponent_TutorialPopup *getTutorialPopup() { return m_tutorialPopup; }
|
||||
UIScene_HUD *getHUD() { return m_hud; }
|
||||
|
||||
@@ -107,8 +107,10 @@ public:
|
||||
int getRenderHeight() { return m_renderHeight; }
|
||||
|
||||
#ifdef __PSVITA__
|
||||
UILayer *GetParentLayer() {return m_parentLayer;}
|
||||
EUIGroup GetParentLayerGroup() {return m_parentLayer->m_parentGroup->GetGroup();}
|
||||
#endif
|
||||
#if defined(__PSVITA__) || defined(_WINDOWS64)
|
||||
UILayer *GetParentLayer() {return m_parentLayer;}
|
||||
vector<UIControl *> *GetControls() {return &m_controls;}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -28,17 +28,6 @@ UIScene_AbstractContainerMenu::UIScene_AbstractContainerMenu(int iPad, UILayer *
|
||||
ui.OverrideSFX(m_iPad,ACTION_MENU_DOWN,true);
|
||||
|
||||
m_bIgnoreInput=false;
|
||||
#ifdef _WINDOWS64
|
||||
m_bMouseDragSlider=false;
|
||||
m_bHasMousePosition = false;
|
||||
m_lastMouseX = 0;
|
||||
m_lastMouseY = 0;
|
||||
|
||||
for (int btn = 0; btn < 3; btn++)
|
||||
{
|
||||
KMInput.ConsumeMousePress(btn);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
UIScene_AbstractContainerMenu::~UIScene_AbstractContainerMenu()
|
||||
@@ -49,6 +38,16 @@ UIScene_AbstractContainerMenu::~UIScene_AbstractContainerMenu()
|
||||
void UIScene_AbstractContainerMenu::handleDestroy()
|
||||
{
|
||||
app.DebugPrintf("UIScene_AbstractContainerMenu::handleDestroy\n");
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
g_savedInventoryCursorPos.x = m_pointerPos.x;
|
||||
g_savedInventoryCursorPos.y = m_pointerPos.y;
|
||||
g_savedInventoryCursorPos.hasSavedPos = true;
|
||||
|
||||
g_KBMInput.SetScreenCursorHidden(false);
|
||||
g_KBMInput.SetCursorHiddenForUI(false);
|
||||
#endif
|
||||
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
if( pMinecraft->localgameModes[m_iPad] != NULL )
|
||||
{
|
||||
@@ -84,6 +83,10 @@ void UIScene_AbstractContainerMenu::InitDataAssociations(int iPad, AbstractConta
|
||||
|
||||
void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, int startIndex)
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
g_KBMInput.SetScreenCursorHidden(true);
|
||||
g_KBMInput.SetCursorHiddenForUI(true);
|
||||
#endif
|
||||
|
||||
m_labelInventory.init( app.GetString(IDS_INVENTORY) );
|
||||
|
||||
@@ -168,6 +171,19 @@ void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, int startIndex)
|
||||
//m_pointerControl->SetPosition( &vPointerPos );
|
||||
m_pointerPos = vPointerPos;
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (g_savedInventoryCursorPos.hasSavedPos)
|
||||
{
|
||||
m_pointerPos.x = g_savedInventoryCursorPos.x;
|
||||
m_pointerPos.y = g_savedInventoryCursorPos.y;
|
||||
|
||||
if (m_pointerPos.x < m_fPointerMinX) m_pointerPos.x = m_fPointerMinX;
|
||||
if (m_pointerPos.x > m_fPointerMaxX) m_pointerPos.x = m_fPointerMaxX;
|
||||
if (m_pointerPos.y < m_fPointerMinY) m_pointerPos.y = m_fPointerMinY;
|
||||
if (m_pointerPos.y > m_fPointerMaxY) m_pointerPos.y = m_fPointerMaxY;
|
||||
}
|
||||
#endif
|
||||
|
||||
IggyEvent mouseEvent;
|
||||
S32 width, height;
|
||||
m_parentLayer->getRenderDimensions(width, height);
|
||||
@@ -190,139 +206,15 @@ void UIScene_AbstractContainerMenu::tick()
|
||||
{
|
||||
UIScene::tick();
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
bool mouseActive = (m_iPad == 0 && !KMInput.IsCaptured());
|
||||
bool drivePointerFromMouse = false;
|
||||
float rawMouseMovieX = 0, rawMouseMovieY = 0;
|
||||
int scrollDelta = 0;
|
||||
// Map Windows mouse position to the virtual pointer in movie coordinates
|
||||
if (mouseActive)
|
||||
{
|
||||
RECT clientRect;
|
||||
GetClientRect(KMInput.GetHWnd(), &clientRect);
|
||||
int clientWidth = clientRect.right;
|
||||
int clientHeight = clientRect.bottom;
|
||||
if (clientWidth > 0 && clientHeight > 0)
|
||||
{
|
||||
int mouseX = KMInput.GetMouseX();
|
||||
int mouseY = KMInput.GetMouseY();
|
||||
bool mouseMoved = !m_bHasMousePosition || mouseX != m_lastMouseX || mouseY != m_lastMouseY;
|
||||
|
||||
m_bHasMousePosition = true;
|
||||
m_lastMouseX = mouseX;
|
||||
m_lastMouseY = mouseY;
|
||||
scrollDelta = KMInput.ConsumeScrollDelta();
|
||||
|
||||
// Convert mouse position to movie coordinates using the movie/client ratio
|
||||
float mx = (float)mouseX * ((float)m_movieWidth / (float)clientWidth) - (float)m_controlMainPanel.getXPos();
|
||||
float my = (float)mouseY * ((float)m_movieHeight / (float)clientHeight) - (float)m_controlMainPanel.getYPos();
|
||||
|
||||
rawMouseMovieX = mx;
|
||||
rawMouseMovieY = my;
|
||||
|
||||
// Once the mouse has taken over the container cursor, keep following the OS cursor
|
||||
// until explicit controller input takes ownership back.
|
||||
drivePointerFromMouse = m_bPointerDrivenByMouse || mouseMoved || KMInput.IsMouseDown(0) || KMInput.IsMouseDown(1) || KMInput.IsMouseDown(2) || scrollDelta != 0;
|
||||
if (drivePointerFromMouse)
|
||||
{
|
||||
m_bPointerDrivenByMouse = true;
|
||||
m_eCurrTapState = eTapStateNoInput;
|
||||
m_pointerPos.x = mx;
|
||||
m_pointerPos.y = my;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
onMouseTick();
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
// Dispatch mouse clicks AFTER onMouseTick() has updated m_eCurrSection from the new pointer position
|
||||
if (mouseActive)
|
||||
{
|
||||
if (KMInput.ConsumeMousePress(0))
|
||||
{
|
||||
if (m_eCurrSection == eSectionInventoryCreativeSlider)
|
||||
{
|
||||
// Scrollbar click: use raw mouse position (onMouseTick may have snapped m_pointerPos)
|
||||
m_bMouseDragSlider = true;
|
||||
m_pointerPos.x = rawMouseMovieX;
|
||||
m_pointerPos.y = rawMouseMovieY;
|
||||
handleOtherClicked(m_iPad, eSectionInventoryCreativeSlider, 0, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
handleKeyDown(m_iPad, ACTION_MENU_A, false);
|
||||
}
|
||||
}
|
||||
else if (m_bMouseDragSlider && KMInput.IsMouseDown(0))
|
||||
{
|
||||
// Continue scrollbar drag: update scroll position from current mouse Y
|
||||
m_pointerPos.x = rawMouseMovieX;
|
||||
m_pointerPos.y = rawMouseMovieY;
|
||||
handleOtherClicked(m_iPad, eSectionInventoryCreativeSlider, 0, false);
|
||||
}
|
||||
|
||||
if (!KMInput.IsMouseDown(0))
|
||||
m_bMouseDragSlider = false;
|
||||
|
||||
if (KMInput.ConsumeMousePress(1))
|
||||
{
|
||||
handleKeyDown(m_iPad, ACTION_MENU_X, false);
|
||||
}
|
||||
if (KMInput.ConsumeMousePress(2))
|
||||
{
|
||||
handleKeyDown(m_iPad, ACTION_MENU_Y, false);
|
||||
}
|
||||
|
||||
// Mouse scroll wheel for page scrolling
|
||||
if (scrollDelta > 0)
|
||||
{
|
||||
handleKeyDown(m_iPad, ACTION_MENU_OTHER_STICK_UP, false);
|
||||
}
|
||||
else if (scrollDelta < 0)
|
||||
{
|
||||
handleKeyDown(m_iPad, ACTION_MENU_OTHER_STICK_DOWN, false);
|
||||
}
|
||||
|
||||
// ESC to close — must be last since it may destroy this scene
|
||||
if (KMInput.ConsumeKeyPress(VK_ESCAPE))
|
||||
{
|
||||
handleKeyDown(m_iPad, ACTION_MENU_B, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
IggyEvent mouseEvent;
|
||||
S32 width, height;
|
||||
m_parentLayer->getRenderDimensions(width, height);
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
S32 x, y;
|
||||
if (mouseActive && m_bPointerDrivenByMouse)
|
||||
{
|
||||
// Send raw mouse position directly as Iggy event to avoid coordinate round-trip errors
|
||||
// Scale mouse client coords to the Iggy display space (which was set to getRenderDimensions())
|
||||
RECT clientRect;
|
||||
GetClientRect(KMInput.GetHWnd(), &clientRect);
|
||||
float mouseMovieX = (float)KMInput.GetMouseX() * ((float)m_movieWidth / (float)clientRect.right);
|
||||
float mouseMovieY = (float)KMInput.GetMouseY() * ((float)m_movieHeight / (float)clientRect.bottom);
|
||||
float mouseLocalX = mouseMovieX - (float)m_controlMainPanel.getXPos();
|
||||
float mouseLocalY = mouseMovieY - (float)m_controlMainPanel.getYPos();
|
||||
S32 x = (S32)(m_pointerPos.x * ((float)width / m_movieWidth));
|
||||
S32 y = (S32)(m_pointerPos.y * ((float)height / m_movieHeight));
|
||||
|
||||
x = (S32)(mouseLocalX * ((float)width / m_movieWidth));
|
||||
y = (S32)(mouseLocalY * ((float)height / m_movieHeight));
|
||||
}
|
||||
else
|
||||
{
|
||||
x = (S32)(m_pointerPos.x * ((float)width / m_movieWidth));
|
||||
y = (S32)(m_pointerPos.y * ((float)height / m_movieHeight));
|
||||
}
|
||||
#else
|
||||
S32 x = m_pointerPos.x*((float)width/m_movieWidth);
|
||||
S32 y = m_pointerPos.y*((float)height/m_movieHeight);
|
||||
#endif
|
||||
IggyMakeEventMouseMove( &mouseEvent, x, y);
|
||||
|
||||
// 4J Stu - This seems to be broken on Durango, so do it ourself
|
||||
|
||||
@@ -10,12 +10,6 @@ class UIScene_AbstractContainerMenu : public UIScene, public virtual IUIScene_Ab
|
||||
private:
|
||||
ESceneSection m_focusSection;
|
||||
bool m_bIgnoreInput;
|
||||
#ifdef _WINDOWS64
|
||||
bool m_bMouseDragSlider;
|
||||
bool m_bHasMousePosition;
|
||||
int m_lastMouseX;
|
||||
int m_lastMouseY;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
UIControl m_controlMainPanel;
|
||||
@@ -42,6 +36,8 @@ public:
|
||||
virtual void handleDestroy();
|
||||
|
||||
int getPad() { return m_iPad; }
|
||||
int getMovieWidth() { return m_movieWidth; }
|
||||
int getMovieHeight() { return m_movieHeight; }
|
||||
bool getIgnoreInput() { return m_bIgnoreInput; }
|
||||
void setIgnoreInput(bool bVal) { m_bIgnoreInput=bVal; }
|
||||
|
||||
|
||||
@@ -1317,6 +1317,14 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, bool pr
|
||||
sendInputToMovie(key, repeat, pressed, released);
|
||||
handled = true;
|
||||
break;
|
||||
case ACTION_MENU_OTHER_STICK_UP:
|
||||
sendInputToMovie(ACTION_MENU_UP, repeat, pressed, released);
|
||||
handled = true;
|
||||
break;
|
||||
case ACTION_MENU_OTHER_STICK_DOWN:
|
||||
sendInputToMovie(ACTION_MENU_DOWN, repeat, pressed, released);
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,33 @@
|
||||
#include "..\..\Minecraft.h"
|
||||
#include "..\..\GameRenderer.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
const int FOV_MIN = 70;
|
||||
const int FOV_MAX = 110;
|
||||
const int FOV_SLIDER_MAX = 100;
|
||||
|
||||
int clampFov(int value)
|
||||
{
|
||||
if (value < FOV_MIN) return FOV_MIN;
|
||||
if (value > FOV_MAX) return FOV_MAX;
|
||||
return value;
|
||||
}
|
||||
|
||||
int fovToSliderValue(float fov)
|
||||
{
|
||||
int clampedFov = clampFov((int)(fov + 0.5f));
|
||||
return ((clampedFov - FOV_MIN) * FOV_SLIDER_MAX) / (FOV_MAX - FOV_MIN);
|
||||
}
|
||||
|
||||
int sliderValueToFov(int sliderValue)
|
||||
{
|
||||
if (sliderValue < 0) sliderValue = 0;
|
||||
if (sliderValue > FOV_SLIDER_MAX) sliderValue = FOV_SLIDER_MAX;
|
||||
return FOV_MIN + ((sliderValue * (FOV_MAX - FOV_MIN)) / FOV_SLIDER_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
||||
{
|
||||
// Setup all the Iggy references we need for this scene
|
||||
@@ -22,8 +49,9 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD
|
||||
swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),app.GetGameSettings(m_iPad,eGameSetting_Gamma));
|
||||
m_sliderGamma.init(TempString,eControl_Gamma,0,100,app.GetGameSettings(m_iPad,eGameSetting_Gamma));
|
||||
|
||||
swprintf((WCHAR*)TempString, 256, L"FOV: %d%%", (int)pMinecraft->gameRenderer->GetFovVal());
|
||||
m_sliderFOV.init(TempString, eControl_FOV, 70, 110, (int)pMinecraft->gameRenderer->GetFovVal());
|
||||
int initialFov = clampFov((int)(pMinecraft->gameRenderer->GetFovVal() + 0.5f));
|
||||
swprintf((WCHAR*)TempString, 256, L"FOV: %d", initialFov);
|
||||
m_sliderFOV.init(TempString, eControl_FOV, 0, FOV_SLIDER_MAX, fovToSliderValue((float)initialFov));
|
||||
|
||||
swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity));
|
||||
m_sliderInterfaceOpacity.init(TempString,eControl_InterfaceOpacity,0,100,app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity));
|
||||
@@ -150,10 +178,12 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal
|
||||
|
||||
case eControl_FOV:
|
||||
{
|
||||
m_sliderFOV.handleSliderMove(value);
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
pMinecraft->gameRenderer->SetFovVal((float)currentValue);
|
||||
int fovValue = sliderValueToFov(value);
|
||||
pMinecraft->gameRenderer->SetFovVal((float)fovValue);
|
||||
WCHAR TempString[256];
|
||||
swprintf((WCHAR*)TempString, 256, L"FOV: %d%%", (int)currentValue);
|
||||
swprintf((WCHAR*)TempString, 256, L"FOV: %d", fovValue);
|
||||
m_sliderFOV.setLabel(TempString);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user