fixed a tooltip bug in spell creation and made controller tooltip toggling a helper function in the window manager

This commit is contained in:
bmdhacks 2025-09-06 09:50:27 -07:00
parent 81fc72a5b8
commit 072504d3b7
7 changed files with 23 additions and 37 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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)
{

View File

@ -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<int>(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);

View File

@ -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)

View File

@ -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