From 072504d3b7ed84624eeb5526718b5254e6b62d61 Mon Sep 17 00:00:00 2001 From: bmdhacks Date: Sat, 6 Sep 2025 09:50:27 -0700 Subject: [PATCH] fixed a tooltip bug in spell creation and made controller tooltip toggling a helper function in the window manager --- apps/openmw/mwbase/windowmanager.hpp | 2 ++ apps/openmw/mwgui/itemview.cpp | 20 +++++--------------- apps/openmw/mwgui/spellbuyingwindow.cpp | 8 ++------ apps/openmw/mwgui/spellcreationdialog.cpp | 2 +- apps/openmw/mwgui/spellview.cpp | 20 +++++--------------- apps/openmw/mwgui/windowmanagerimp.cpp | 7 +++++++ apps/openmw/mwgui/windowmanagerimp.hpp | 1 + 7 files changed, 23 insertions(+), 37 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 440eb073d7..2e0e9a7b7d 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -396,6 +396,8 @@ namespace MWBase virtual void setControllerTooltipVisible(bool visible) = 0; virtual bool getControllerTooltipEnabled() const = 0; virtual void setControllerTooltipEnabled(bool enabled) = 0; + /// Restore tooltip visibility if user has them enabled but they were hidden by mouse movement + virtual void restoreControllerTooltips() = 0; virtual void updateControllerButtonsOverlay() = 0; // Used in Lua bindings diff --git a/apps/openmw/mwgui/itemview.cpp b/apps/openmw/mwgui/itemview.cpp index 3016d254ab..89d764c845 100644 --- a/apps/openmw/mwgui/itemview.cpp +++ b/apps/openmw/mwgui/itemview.cpp @@ -223,34 +223,26 @@ namespace MWGui updateControllerFocus(-1, mControllerFocus); break; case SDL_CONTROLLER_BUTTON_DPAD_UP: - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); if (mControllerFocus % mRows == 0) mControllerFocus = std::min(mControllerFocus + mRows - 1, mItemCount - 1); else mControllerFocus--; break; case SDL_CONTROLLER_BUTTON_DPAD_DOWN: - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); if (mControllerFocus % mRows == mRows - 1 || mControllerFocus == mItemCount - 1) mControllerFocus -= mControllerFocus % mRows; else mControllerFocus++; break; case SDL_CONTROLLER_BUTTON_DPAD_LEFT: - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); if (mControllerFocus >= mRows) mControllerFocus -= mRows; break; case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); if (mControllerFocus + mRows < mItemCount) mControllerFocus += mRows; else if (mControllerFocus / mRows != (mItemCount - 1) / mRows) @@ -297,10 +289,8 @@ namespace MWGui else mScrollView->setViewOffset(MyGUI::IntPoint(-42 * (column - 3), 0)); - // Restore tooltip visibility if user has them enabled but they were hidden by mouse movement MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager(); - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); if (winMgr->getControllerTooltipVisible()) MWBase::Environment::get().getInputManager()->warpMouseToWidget(focused); diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 35a67b323a..a1e5fecd1e 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -248,9 +248,7 @@ namespace MWGui } else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP) { - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); if (mSpellButtons.size() <= 1) return true; @@ -261,9 +259,7 @@ namespace MWGui } else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) { - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); if (mSpellButtons.size() <= 1) return true; diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 78246d4521..bd4728928b 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -1058,7 +1058,7 @@ namespace MWGui else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK) { // Toggle info tooltip - winMgr->setControllerTooltipVisible(!mRightColumn && !winMgr->getControllerTooltipVisible()); + winMgr->setControllerTooltipEnabled(!winMgr->getControllerTooltipEnabled()); } else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP) { diff --git a/apps/openmw/mwgui/spellview.cpp b/apps/openmw/mwgui/spellview.cpp index d79a90b0d6..8c64c92ce6 100644 --- a/apps/openmw/mwgui/spellview.cpp +++ b/apps/openmw/mwgui/spellview.cpp @@ -367,27 +367,19 @@ namespace MWGui winMgr->setControllerTooltipEnabled(!winMgr->getControllerTooltipEnabled()); break; case SDL_CONTROLLER_BUTTON_DPAD_UP: - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); mControllerFocus--; break; case SDL_CONTROLLER_BUTTON_DPAD_DOWN: - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); mControllerFocus++; break; case SDL_CONTROLLER_BUTTON_DPAD_LEFT: - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); mControllerFocus = std::max(0, mControllerFocus - 10); break; case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: - // Restore tooltip visibility if user has them enabled but they were hidden by mouse - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); mControllerFocus = std::min(mControllerFocus + 10, static_cast(mButtons.size()) - 1); break; case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: @@ -463,10 +455,8 @@ namespace MWGui mScrollView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5))); } - // Restore tooltip visibility if user has them enabled but they were hidden by mouse movement MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager(); - if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) - winMgr->setControllerTooltipVisible(true); + winMgr->restoreControllerTooltips(); if (winMgr->getControllerTooltipVisible()) MWBase::Environment::get().getInputManager()->warpMouseToWidget(focused); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 682340533f..15b5b20258 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -2660,6 +2660,13 @@ namespace MWGui mControllerTooltipVisible = enabled; } + void WindowManager::restoreControllerTooltips() + { + // Restore tooltip visibility if user has them enabled but they were hidden by mouse movement + if (mControllerTooltipEnabled && !mControllerTooltipVisible) + setControllerTooltipVisible(true); + } + void WindowManager::updateControllerButtonsOverlay() { if (!Settings::gui().mControllerMenus || !mControllerButtonsOverlay) diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index a79581ecac..a9acaffcf0 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -399,6 +399,7 @@ namespace MWGui void setControllerTooltipVisible(bool visible) override; bool getControllerTooltipEnabled() const override { return mControllerTooltipEnabled; } void setControllerTooltipEnabled(bool enabled) override; + void restoreControllerTooltips() override; void updateControllerButtonsOverlay() override; // Used in Lua bindings