From 8ae193abe8fa3ceaaf5f5a0956ac82740cd4991e Mon Sep 17 00:00:00 2001 From: Andrew Lanzone Date: Mon, 2 Jun 2025 00:11:01 -0700 Subject: [PATCH] Fix issue when selecting an inventory item with the tooltip visible --- apps/openmw/mwgui/inventorywindow.cpp | 5 +++++ apps/openmw/mwgui/inventorywindow.hpp | 1 + apps/openmw/mwgui/itemview.hpp | 1 + apps/openmw/mwinput/controllermanager.cpp | 9 +++++++++ 4 files changed, 16 insertions(+) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index d9061ebc9e..99af4d63a3 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -880,6 +880,11 @@ namespace MWGui return osg::Vec2f(normalisedX * float(viewport.width - 1), (1.0 - normalisedY) * float(viewport.height - 1)); } + bool InventoryWindow::isControllerTooltipVisible() + { + return mItemView->isControllerTooltipVisible(); + } + ControllerButtonStr* InventoryWindow::getControllerButtons() { switch (mGuiMode) diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 5b4d61f272..86f31191f9 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -68,6 +68,7 @@ namespace MWGui std::string_view getWindowIdForLua() const override { return "Inventory"; } ControllerButtonStr* getControllerButtons() override; + bool isControllerTooltipVisible(); protected: void onTitleDoubleClicked() override; diff --git a/apps/openmw/mwgui/itemview.hpp b/apps/openmw/mwgui/itemview.hpp index 29d44c6b09..2f5cb99846 100644 --- a/apps/openmw/mwgui/itemview.hpp +++ b/apps/openmw/mwgui/itemview.hpp @@ -35,6 +35,7 @@ namespace MWGui void setActiveControllerWindow(bool active); int getControllerFocus() { return mControllerFocus; } int getItemCount() { return mItemCount; } + bool isControllerTooltipVisible() { return mControllerTooltip; } void onControllerButton(const unsigned char button); private: diff --git a/apps/openmw/mwinput/controllermanager.cpp b/apps/openmw/mwinput/controllermanager.cpp index 48034cae01..1647a5bab2 100644 --- a/apps/openmw/mwinput/controllermanager.cpp +++ b/apps/openmw/mwinput/controllermanager.cpp @@ -16,6 +16,7 @@ #include "../mwbase/luamanager.hpp" #include "../mwbase/statemanager.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwgui/inventorywindow.hpp" #include "actions.hpp" #include "bindingsmanager.hpp" @@ -252,6 +253,14 @@ namespace MWInput MWGui::WindowBase* topWin = winMgr->getActiveControllerWindow(); if (topWin) { + // When the inventory tooltip is visible, we don't actually want the A button to + // act like a mouse button; it should act normally. + if (treatAsMouse + && arg.button == SDL_CONTROLLER_BUTTON_A + && (MWGui::InventoryWindow *)topWin == winMgr->getInventoryWindow() + && ((MWGui::InventoryWindow *)topWin)->isControllerTooltipVisible()) + treatAsMouse = false; + mGamepadGuiCursorEnabled = topWin->isGamepadCursorAllowed(); // Fall through to mouse click