Controller tooltip display preferences survive mouse movement

This commit is contained in:
bmdhacks 2025-08-16 11:53:54 -07:00
parent 1dbd5fd571
commit 12aef44fe1
4 changed files with 28 additions and 2 deletions

View File

@ -394,6 +394,8 @@ namespace MWBase
virtual void setActiveControllerWindow(MWGui::GuiMode mode, int activeIndex) = 0;
virtual bool getControllerTooltip() const = 0;
virtual void setControllerTooltip(bool enabled) = 0;
virtual bool getControllerTooltipUserPreference() const = 0;
virtual void setControllerTooltipUserPreference(bool enabled) = 0;
virtual void updateControllerButtonsOverlay() = 0;
// Used in Lua bindings

View File

@ -205,6 +205,7 @@ namespace MWGui
return;
int prevFocus = mControllerFocus;
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
switch (button)
{
@ -218,27 +219,34 @@ namespace MWGui
break;
case SDL_CONTROLLER_BUTTON_RIGHTSTICK:
// Toggle info tooltip
MWBase::Environment::get().getWindowManager()->setControllerTooltip(
!MWBase::Environment::get().getWindowManager()->getControllerTooltip());
winMgr->setControllerTooltipUserPreference(!winMgr->getControllerTooltip());
updateControllerFocus(-1, mControllerFocus);
break;
case SDL_CONTROLLER_BUTTON_DPAD_UP:
if (winMgr->getControllerTooltipUserPreference() && !winMgr->getControllerTooltip())
winMgr->setControllerTooltip(true);
if (mControllerFocus % mRows == 0)
mControllerFocus = std::min(mControllerFocus + mRows - 1, mItemCount - 1);
else
mControllerFocus--;
break;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
if (winMgr->getControllerTooltipUserPreference() && !winMgr->getControllerTooltip())
winMgr->setControllerTooltip(true);
if (mControllerFocus % mRows == mRows - 1 || mControllerFocus == mItemCount - 1)
mControllerFocus -= mControllerFocus % mRows;
else
mControllerFocus++;
break;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
if (winMgr->getControllerTooltipUserPreference() && !winMgr->getControllerTooltip())
winMgr->setControllerTooltip(true);
if (mControllerFocus >= mRows)
mControllerFocus -= mRows;
break;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
if (winMgr->getControllerTooltipUserPreference() && !winMgr->getControllerTooltip())
winMgr->setControllerTooltip(true);
if (mControllerFocus + mRows < mItemCount)
mControllerFocus += mRows;
else if (mControllerFocus / mRows != (mItemCount - 1) / mRows)

View File

@ -519,6 +519,8 @@ namespace MWGui
auto inventoryTabsOverlay = std::make_unique<InventoryTabsOverlay>();
mInventoryTabsOverlay = inventoryTabsOverlay.get();
mWindows.push_back(std::move(inventoryTabsOverlay));
mControllerTooltipUserPreference = Settings::gui().mControllerTooltips;
mActiveControllerWindows[GM_Inventory] = 1; // Start on Inventory page
mInputBlocker = MyGUI::Gui::getInstance().createWidget<MyGUI::Widget>(
@ -2648,6 +2650,15 @@ namespace MWGui
mControllerTooltip = enabled;
}
void WindowManager::setControllerTooltipUserPreference(bool enabled)
{
if (!Settings::gui().mControllerMenus)
return;
mControllerTooltipUserPreference = enabled;
mControllerTooltip = enabled;
}
void WindowManager::updateControllerButtonsOverlay()
{
if (!Settings::gui().mControllerMenus || !mControllerButtonsOverlay)

View File

@ -397,6 +397,8 @@ namespace MWGui
void setActiveControllerWindow(GuiMode mode, int activeIndex) override;
bool getControllerTooltip() const override { return mControllerTooltip; }
void setControllerTooltip(bool enabled) override;
bool getControllerTooltipUserPreference() const override { return mControllerTooltipUserPreference; }
void setControllerTooltipUserPreference(bool enabled) override;
void updateControllerButtonsOverlay() override;
// Used in Lua bindings
@ -511,7 +513,10 @@ namespace MWGui
std::vector<GuiMode> mGuiModes;
// The active window for controller mode for each GUI mode.
std::map<GuiMode, int> mActiveControllerWindows;
// Current tooltip state (can be disabled by mouse movement)
bool mControllerTooltip = false;
// Toggleable preference. Restores tooltips on controller input after pointer movement
bool mControllerTooltipUserPreference = false;
void reapplyActiveControllerWindow();