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 void setActiveControllerWindow(MWGui::GuiMode mode, int activeIndex) = 0;
virtual bool getControllerTooltip() const = 0; virtual bool getControllerTooltip() const = 0;
virtual void setControllerTooltip(bool enabled) = 0; virtual void setControllerTooltip(bool enabled) = 0;
virtual bool getControllerTooltipUserPreference() const = 0;
virtual void setControllerTooltipUserPreference(bool enabled) = 0;
virtual void updateControllerButtonsOverlay() = 0; virtual void updateControllerButtonsOverlay() = 0;
// Used in Lua bindings // Used in Lua bindings

View File

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

View File

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

View File

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