diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index adf40739..54e580e2 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -915,7 +915,7 @@ void UIController::tickInput() { int hitControlId = -1; S32 hitArea = INT_MAX; - UIControl *hitCtrl = NULL; + UIControl *hitCtrl = nullptr; for (size_t i = 0; i < controls->size(); ++i) { UIControl *ctrl = (*controls)[i]; @@ -952,11 +952,18 @@ void UIController::tickInput() { // ButtonList manages focus internally via Flash — // pass mouse coords so it can highlight the right item. - static_cast(ctrl)->SetTouchFocus( - static_cast(sceneMouseX), static_cast(sceneMouseY), false); + S32 adjustedMouseY = static_cast(sceneMouseY); + if (pScene->getSceneType() == eUIScene_LoadCreateJoinMenu) + { + const S32 visibleRows = 7.0f; + const F32 rowHeight = (visibleRows > 0.0f) ? (static_cast(ch) / visibleRows) : 0.0f; + if (rowHeight > 0.0f) + adjustedMouseY -= rowHeight; + } + static_cast(ctrl)->SetTouchFocus(static_cast(sceneMouseX), static_cast(fAdjustedMouseY), false); hitControlId = -1; hitArea = INT_MAX; - hitCtrl = NULL; + hitCtrl = nullptr; break; // ButtonList takes priority } if (type == UIControl::eTexturePackList) @@ -969,7 +976,7 @@ void UIController::tickInput() m_bMouseHoverHorizontalList = true; hitControlId = -1; hitArea = INT_MAX; - hitCtrl = NULL; + hitCtrl = nullptr; break; } S32 area = cw * ch; diff --git a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp index f9f63128..716a9752 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp @@ -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(cy) + topInset; - const float contentBottom = static_cast(cy + ch) - bottomInset; - if (contentBottom <= contentTop) - return; - - if (sceneMouseY < contentTop || sceneMouseY > contentBottom) - return; - - const float rowHeight = (contentBottom - contentTop) / static_cast(visibleRows); - if (rowHeight <= 0.0f) - return; - - const float hoverOffset = (sceneMouseY - contentTop) / rowHeight; - int hoverRow = static_cast(hoverOffset); - if (hoverRow < 0) - hoverRow = 0; - if (hoverRow >= visibleRows) - hoverRow = visibleRows - 1; - const float hoverRowFraction = hoverOffset - static_cast(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(g_KBMInput.GetMouseX()); - sceneMouseY = static_cast(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(winW)); - const float screenY = sceneMouseY * (ui.getScreenHeight() / static_cast(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(vpOriginX) + fitOffsetX; - const S32 originY = static_cast(vpOriginY) + fitOffsetY; - displayW = fitW; - displayH = fitH; - - if (displayW <= 0 || displayH <= 0) - return false; - - sceneMouseX = (screenX - originX) * (static_cast(getRenderWidth()) / static_cast(displayW)); - sceneMouseY = (screenY - originY) * (static_cast(getRenderHeight()) / static_cast(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) { diff --git a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.h b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.h index 75cc0362..1ea7a75a 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.h @@ -68,7 +68,6 @@ protected: UIControl_SaveList m_buttonListSaves; UIControl_SaveList m_buttonListNewGames; UIControl_SaveList m_buttonListGames; - UIControl_Button m_tabLoad, m_tabCreate, m_tabJoin; UIControl_Label m_labelSavesListTitle, m_labelCreateListTitle, m_labelJoinListTitle, m_labelNoGames; UIControl m_controlSavesTimer, m_controlNewGameTimer, m_controlJoinTimer; #if defined(_XBOX_ONE) || defined(__ORBIS__) || defined(_WINDOWS64) @@ -90,13 +89,10 @@ protected: private: UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) - UI_MAP_ELEMENT( m_controlMainPanel, "MainPanel") UI_MAP_ELEMENT( m_controlLoadGame, "LoadGame") UI_BEGIN_MAP_CHILD_ELEMENTS( m_controlLoadGame ) - UI_MAP_ELEMENT( m_controlLoadGamePanel, "LoadGameListRecessPanel") UI_MAP_ELEMENT( m_buttonListSaves, "LoadGameList") UI_MAP_ELEMENT( m_controlSavesTimer, "LoadGameTimer") - UI_MAP_ELEMENT( m_tabLoad, "TouchTabLoad") #if defined(_XBOX_ONE) || defined(__ORBIS__) || defined(_WINDOWS64) UI_MAP_ELEMENT( m_spaceIndicatorSaves, "SaveSizeBar") #endif @@ -104,24 +100,19 @@ private: UI_MAP_ELEMENT( m_controlNewGame, "NewGame") UI_BEGIN_MAP_CHILD_ELEMENTS( m_controlNewGame ) - UI_MAP_ELEMENT( m_controlNewGamePanel, "NewGameListRecessPanel") UI_MAP_ELEMENT( m_buttonListNewGames, "NewGameList") UI_MAP_ELEMENT( m_controlNewGameTimer, "NewGameTimer") - UI_MAP_ELEMENT( m_tabCreate, "TouchTabCreate") UI_END_MAP_CHILD_ELEMENTS() UI_MAP_ELEMENT( m_controlJoinGame, "JoinGame") UI_BEGIN_MAP_CHILD_ELEMENTS( m_controlJoinGame ) - UI_MAP_ELEMENT( m_controlJoinGamePanel, "GamesPanel") UI_MAP_ELEMENT( m_buttonListGames, "JoinGameGamesList") UI_MAP_ELEMENT( m_controlJoinTimer, "JoinGamesTimer") - UI_MAP_ELEMENT( m_tabJoin, "TouchTabJoin") UI_END_MAP_CHILD_ELEMENTS() UI_MAP_ELEMENT( m_labelSavesListTitle, "LoadGameTabTitle") UI_MAP_ELEMENT( m_labelCreateListTitle, "NewGameTabTitle") UI_MAP_ELEMENT( m_labelJoinListTitle, "JoinGameTabTitle") - UI_MAP_ELEMENT( m_labelNoGames, "NoGames") UI_MAP_NAME( m_funcSetActiveTab, L"SetActiveTab") UI_MAP_NAME( m_funcSetMatchesAvailable, L"SetMatchesAvailable") UI_MAP_NAME( m_funcShowSaveSizeBar, L"ShowSaveSizeBar") @@ -216,11 +207,6 @@ private: void RebuildJoinGamesListVisual(bool syncFocus); void UpdateJoinTabAvailability(); void UpdateSaveSizeBarVisibility(); -#ifdef _WINDOWS64 - void UpdateMouseHoverForActiveTab(); - bool ConvertMouseToSceneCoords(float &sceneMouseX, float &sceneMouseY); - void GetAbsoluteControlRect(UIControl *pControl, S32 &x, S32 &y, S32 &w, S32 &h); -#endif protected: // TODO: This should be pure virtual in this class