mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/GabsPuNs-MinecraftConsoles.git
synced 2026-06-29 09:46:00 +00:00
Fix mouse for 1080p
This commit is contained in:
@@ -595,9 +595,6 @@ void UIScene_LoadCreateJoinMenu::handleGainFocus(bool navBack)
|
||||
|
||||
m_controlJoinTimer.setVisible(false);
|
||||
|
||||
if (m_bHasNoGamesLabel)
|
||||
m_labelNoGames.setVisible(false);
|
||||
|
||||
#if TO_BE_IMPLEMENTED
|
||||
|
||||
m_SavesList.InitFocus(m_iPad);
|
||||
@@ -739,236 +736,6 @@ int UIScene_LoadCreateJoinMenu::LoadSaveCallback(LPVOID lpParam, bool bRes)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
void UIScene_LoadCreateJoinMenu::UpdateMouseHoverForActiveTab()
|
||||
{
|
||||
if (!hasFocus(m_iPad) || getMovie() == nullptr || g_KBMInput.IsMouseGrabbed() || !g_KBMInput.IsKBMActive())
|
||||
return;
|
||||
|
||||
if (m_bIgnoreInput)
|
||||
return;
|
||||
|
||||
const int rawMouseX = g_KBMInput.GetMouseX();
|
||||
const int rawMouseY = g_KBMInput.GetMouseY();
|
||||
if (m_mouseHoverTracked && rawMouseX == m_lastHoverMouseX && rawMouseY == m_lastHoverMouseY)
|
||||
return;
|
||||
|
||||
m_lastHoverMouseX = rawMouseX;
|
||||
m_lastHoverMouseY = rawMouseY;
|
||||
m_mouseHoverTracked = true;
|
||||
|
||||
float sceneMouseX = 0.0f;
|
||||
float sceneMouseY = 0.0f;
|
||||
if (!ConvertMouseToSceneCoords(sceneMouseX, sceneMouseY))
|
||||
return;
|
||||
|
||||
UIControl_ButtonList* pActiveList = nullptr;
|
||||
switch (m_activeTab)
|
||||
{
|
||||
case eTab_Load:
|
||||
pActiveList = &m_buttonListSaves;
|
||||
break;
|
||||
case eTab_Create:
|
||||
pActiveList = &m_buttonListNewGames;
|
||||
break;
|
||||
case eTab_Join:
|
||||
pActiveList = &m_buttonListGames;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (pActiveList == nullptr || pActiveList->getHidden() || !pActiveList->getVisible())
|
||||
return;
|
||||
|
||||
S32 cx = 0, cy = 0, cw = 0, ch = 0;
|
||||
GetAbsoluteControlRect(pActiveList, cx, cy, cw, ch);
|
||||
if (cw <= 0 || ch <= 0)
|
||||
return;
|
||||
|
||||
if (sceneMouseX < cx || sceneMouseX > cx + cw || sceneMouseY < cy || sceneMouseY > cy + ch)
|
||||
return;
|
||||
|
||||
const int itemCount = pActiveList->getItemCount();
|
||||
if (itemCount <= 0)
|
||||
return;
|
||||
|
||||
int visibleRows = 7;
|
||||
float topInset = 6.0f;
|
||||
float bottomInset = 22.0f;
|
||||
switch (m_activeTab)
|
||||
{
|
||||
case eTab_Load:
|
||||
visibleRows = 7;
|
||||
bottomInset = 22.0f;
|
||||
break;
|
||||
case eTab_Create:
|
||||
visibleRows = 7;
|
||||
bottomInset = 22.0f;
|
||||
break;
|
||||
case eTab_Join:
|
||||
visibleRows = 7;
|
||||
bottomInset = 22.0f;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
const float contentTop = static_cast<float>(cy) + topInset;
|
||||
const float contentBottom = static_cast<float>(cy + ch) - bottomInset;
|
||||
if (contentBottom <= contentTop)
|
||||
return;
|
||||
|
||||
if (sceneMouseY < contentTop || sceneMouseY > contentBottom)
|
||||
return;
|
||||
|
||||
const float rowHeight = (contentBottom - contentTop) / static_cast<float>(visibleRows);
|
||||
if (rowHeight <= 0.0f)
|
||||
return;
|
||||
|
||||
const float hoverOffset = (sceneMouseY - contentTop) / rowHeight;
|
||||
int hoverRow = static_cast<int>(hoverOffset);
|
||||
if (hoverRow < 0)
|
||||
hoverRow = 0;
|
||||
if (hoverRow >= visibleRows)
|
||||
hoverRow = visibleRows - 1;
|
||||
const float hoverRowFraction = hoverOffset - static_cast<float>(hoverRow);
|
||||
|
||||
int* pBaseIndex = nullptr;
|
||||
switch (m_activeTab)
|
||||
{
|
||||
case eTab_Load:
|
||||
pBaseIndex = &m_hoverBaseIndexLoad;
|
||||
break;
|
||||
case eTab_Create:
|
||||
pBaseIndex = &m_hoverBaseIndexCreate;
|
||||
break;
|
||||
case eTab_Join:
|
||||
pBaseIndex = &m_hoverBaseIndexJoin;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
const int maxBaseIndex = (itemCount - visibleRows > 0) ? (itemCount - visibleRows) : 0;
|
||||
if (*pBaseIndex < 0)
|
||||
*pBaseIndex = 0;
|
||||
if (*pBaseIndex > maxBaseIndex)
|
||||
*pBaseIndex = maxBaseIndex;
|
||||
|
||||
if (itemCount > visibleRows)
|
||||
{
|
||||
if (hoverRow == 0 && hoverRowFraction < 0.30f && *pBaseIndex > 0)
|
||||
--(*pBaseIndex);
|
||||
else if (hoverRow == (visibleRows - 1) && hoverRowFraction > 0.70f && *pBaseIndex < maxBaseIndex)
|
||||
++(*pBaseIndex);
|
||||
}
|
||||
|
||||
const int targetChildIndex = ((*pBaseIndex + hoverRow) < (itemCount - 1))
|
||||
? (*pBaseIndex + hoverRow)
|
||||
: (itemCount - 1);
|
||||
|
||||
switch (m_activeTab)
|
||||
{
|
||||
case eTab_Load:
|
||||
if (m_iSaveListIndex == targetChildIndex)
|
||||
return;
|
||||
m_iSaveListIndex = targetChildIndex;
|
||||
m_bUpdateSaveSize = true;
|
||||
break;
|
||||
|
||||
case eTab_Create:
|
||||
if (m_iNewGameListIndex == targetChildIndex)
|
||||
return;
|
||||
m_iNewGameListIndex = targetChildIndex;
|
||||
break;
|
||||
|
||||
case eTab_Join:
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
const int targetGameIndex = targetChildIndex - 1;
|
||||
#else
|
||||
const int targetGameIndex = targetChildIndex;
|
||||
#endif
|
||||
if (m_iGameListIndex == targetGameIndex)
|
||||
return;
|
||||
m_iGameListIndex = targetGameIndex;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
updateTooltips();
|
||||
m_bPendingSaveSizeBarRefresh = true;
|
||||
m_bPendingJoinTabAvailabilityRefresh = true;
|
||||
}
|
||||
|
||||
bool UIScene_LoadCreateJoinMenu::ConvertMouseToSceneCoords(float& sceneMouseX, float& sceneMouseY)
|
||||
{
|
||||
if (g_KBMInput.IsMouseGrabbed() || !g_KBMInput.IsKBMActive())
|
||||
return false;
|
||||
|
||||
sceneMouseX = static_cast<float>(g_KBMInput.GetMouseX());
|
||||
sceneMouseY = static_cast<float>(g_KBMInput.GetMouseY());
|
||||
|
||||
extern HWND g_hWnd;
|
||||
RECT rc = {};
|
||||
if (!g_hWnd || !GetClientRect(g_hWnd, &rc))
|
||||
return false;
|
||||
|
||||
const int winW = rc.right - rc.left;
|
||||
const int winH = rc.bottom - rc.top;
|
||||
if (winW <= 0 || winH <= 0)
|
||||
return false;
|
||||
|
||||
const float screenX = sceneMouseX * (ui.getScreenWidth() / static_cast<float>(winW));
|
||||
const float screenY = sceneMouseY * (ui.getScreenHeight() / static_cast<float>(winH));
|
||||
|
||||
C4JRender::eViewportType vp = GetParentLayer()->getViewport();
|
||||
S32 displayW = 0, displayH = 0;
|
||||
|
||||
F32 vpOriginX = 0, vpOriginY = 0, vpW = 0, vpH = 0;
|
||||
GetViewportRect(ui.getScreenWidth(), ui.getScreenHeight(), vp, vpOriginX, vpOriginY, vpW, vpH);
|
||||
|
||||
S32 fitW = 0, fitH = 0, fitOffsetX = 0, fitOffsetY = 0;
|
||||
Fit16x9(vpW, vpH, fitW, fitH, fitOffsetX, fitOffsetY);
|
||||
|
||||
const S32 originX = static_cast<S32>(vpOriginX) + fitOffsetX;
|
||||
const S32 originY = static_cast<S32>(vpOriginY) + fitOffsetY;
|
||||
displayW = fitW;
|
||||
displayH = fitH;
|
||||
|
||||
if (displayW <= 0 || displayH <= 0)
|
||||
return false;
|
||||
|
||||
sceneMouseX = (screenX - originX) * (static_cast<float>(getRenderWidth()) / static_cast<float>(displayW));
|
||||
sceneMouseY = (screenY - originY) * (static_cast<float>(getRenderHeight()) / static_cast<float>(displayH));
|
||||
return true;
|
||||
}
|
||||
|
||||
void UIScene_LoadCreateJoinMenu::GetAbsoluteControlRect(UIControl* pControl, S32& x, S32& y, S32& w, S32& h)
|
||||
{
|
||||
x = y = w = h = 0;
|
||||
if (!pControl)
|
||||
return;
|
||||
|
||||
pControl->UpdateControl();
|
||||
x = pControl->getXPos();
|
||||
y = pControl->getYPos();
|
||||
w = pControl->getWidth();
|
||||
h = pControl->getHeight();
|
||||
|
||||
UIControl* panel = pControl->getParentPanel();
|
||||
while (panel)
|
||||
{
|
||||
panel->UpdateControl();
|
||||
x += panel->getXPos();
|
||||
y += panel->getYPos();
|
||||
panel = panel->getParentPanel();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void UIScene_LoadCreateJoinMenu::handleTimerComplete(int id)
|
||||
|
||||
{
|
||||
@@ -2362,9 +2129,6 @@ void UIScene_LoadCreateJoinMenu::UpdateGamesList()
|
||||
|
||||
m_controlJoinTimer.setVisible(false);
|
||||
|
||||
if (m_bHasNoGamesLabel)
|
||||
m_labelNoGames.setVisible(true);
|
||||
|
||||
#if TO_BE_IMPLEMENTED
|
||||
|
||||
if (gamesListHasFocus)
|
||||
@@ -2600,25 +2364,16 @@ void UIScene_LoadCreateJoinMenu::ApplyTabVisibility(bool setFocus)
|
||||
|
||||
m_controlLoadGame.setVisible(showLoad);
|
||||
|
||||
m_controlLoadGamePanel.setVisible(showLoad);
|
||||
|
||||
m_buttonListSaves.setVisible(showLoad);
|
||||
|
||||
m_controlNewGame.setVisible(showCreate);
|
||||
|
||||
m_controlNewGamePanel.setVisible(showCreate);
|
||||
|
||||
m_buttonListNewGames.setVisible(showCreate);
|
||||
|
||||
m_controlJoinGame.setVisible(showJoin);
|
||||
|
||||
m_controlJoinGamePanel.setVisible(showJoin);
|
||||
|
||||
m_buttonListGames.setVisible(showJoin);
|
||||
|
||||
if (m_bHasNoGamesLabel)
|
||||
m_labelNoGames.setVisible(showJoin && m_buttonListGames.getItemCount() == 0);
|
||||
|
||||
if (setFocus)
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user