From fbadb6ac392cf64b03f99ab87a64336acd847077 Mon Sep 17 00:00:00 2001 From: MrTheShy <49885496+MrTheShy@users.noreply.github.com> Date: Fri, 6 Mar 2026 17:13:39 +0100 Subject: [PATCH] Remap scroll wheel to LEFT/RIGHT for horizontal controls The scroll wheel was always remapped to UP/DOWN, which is fine for vertical lists but useless on horizontal controls like sliders and the texture pack selector. Track whether the mouse is hovering a horizontal control during the hover hit-test (new bool m_bMouseHoverHorizontalList, set for eTexturePackList and eSlider). When the flag is set, handleKeyPress emits LEFT/RIGHT instead of UP/DOWN for wheel events. TexturePackList is also now part of the mouse hover system with proper hit-testing, relative-coord SetTouchFocus and GetRealHeight for accurate bounds. --- Minecraft.Client/Common/UI/UIController.cpp | 33 ++++++++++++++++++--- Minecraft.Client/Common/UI/UIController.h | 1 + 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 3907ed45c..489a08e82 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -3,6 +3,7 @@ #include "UI.h" #include "UIScene.h" #include "UIControl_Slider.h" +#include "UIControl_TexturePackList.h" #include "..\..\..\Minecraft.World\StringHelpers.h" #include "..\..\LocalPlayer.h" #include "..\..\DLCTexturePack.h" @@ -238,6 +239,7 @@ UIController::UIController() m_mouseDraggingSliderScene = eUIScene_COUNT; m_mouseDraggingSliderId = -1; m_mouseClickConsumedByScene = false; + m_bMouseHoverHorizontalList = false; m_lastHoverMouseX = -1; m_lastHoverMouseY = -1; m_accumulatedTicks = 0; @@ -856,6 +858,7 @@ void UIController::tickInput() // use their own SetTouchFocus for Flash-side hit testing. if (mouseMoved) { + m_bMouseHoverHorizontalList = false; vector *controls = pScene->GetControls(); if (controls) { @@ -871,7 +874,7 @@ void UIController::tickInput() UIControl::eUIControlType type = ctrl->getControlType(); if (type != UIControl::eButton && type != UIControl::eTextInput && type != UIControl::eCheckBox && type != UIControl::eSlider && - type != UIControl::eButtonList) + type != UIControl::eButtonList && type != UIControl::eTexturePackList) continue; // If the scene has an active panel (e.g. tab menus), @@ -884,6 +887,10 @@ void UIController::tickInput() S32 cy = ctrl->getYPos() + panelOffsetY; S32 cw = ctrl->getWidth(); S32 ch = ctrl->getHeight(); + // TexturePackList origin is where the slot area starts, + // not the top-left of the whole control — use GetRealHeight. + if (type == UIControl::eTexturePackList) + ch = ((UIControl_TexturePackList *)ctrl)->GetRealHeight(); if (cw <= 0 || ch <= 0) continue; @@ -901,12 +908,27 @@ void UIController::tickInput() hitCtrl = NULL; break; // ButtonList takes priority } + if (type == UIControl::eTexturePackList) + { + // TexturePackList expects coords relative to its origin. + UIControl_TexturePackList *pList = (UIControl_TexturePackList *)ctrl; + pScene->SetFocusToElement(ctrl->getId()); + pList->SetTouchFocus( + (S32)(sceneMouseX - cx), (S32)(sceneMouseY - cy), false); + m_bMouseHoverHorizontalList = true; + hitControlId = -1; + hitArea = INT_MAX; + hitCtrl = NULL; + break; + } S32 area = cw * ch; if (area < hitArea) { hitControlId = ctrl->getId(); hitArea = area; hitCtrl = ctrl; + if (type == UIControl::eSlider) + m_bMouseHoverHorizontalList = true; } } } @@ -1344,11 +1366,14 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) down = true; } - // Remap scroll wheel to UP/DOWN so all scenes get it without - // needing per-scene OTHER_STICK handling. + // Remap scroll wheel to navigation actions. Use LEFT/RIGHT when + // hovering a horizontal list (e.g. TexturePackList), UP/DOWN otherwise. if (pressed && g_KBMInput.IsKBMActive()) { - key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_UP : ACTION_MENU_DOWN; + if (m_bMouseHoverHorizontalList) + key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_LEFT : ACTION_MENU_RIGHT; + else + key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_UP : ACTION_MENU_DOWN; } } } diff --git a/Minecraft.Client/Common/UI/UIController.h b/Minecraft.Client/Common/UI/UIController.h index 46983c100..7a0c6075c 100644 --- a/Minecraft.Client/Common/UI/UIController.h +++ b/Minecraft.Client/Common/UI/UIController.h @@ -161,6 +161,7 @@ private: EUIScene m_mouseDraggingSliderScene; int m_mouseDraggingSliderId; bool m_mouseClickConsumedByScene; + bool m_bMouseHoverHorizontalList; int m_lastHoverMouseX; int m_lastHoverMouseY; //bool m_bSysUIShowing;