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 void setControllerTooltipVisible(bool visible) = 0;
virtual bool getControllerTooltipEnabled() const = 0; virtual bool getControllerTooltipEnabled() const = 0;
virtual void setControllerTooltipEnabled(bool enabled) = 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; virtual void updateControllerButtonsOverlay() = 0;
// Used in Lua bindings // Used in Lua bindings

View File

@ -223,34 +223,26 @@ namespace MWGui
updateControllerFocus(-1, mControllerFocus); updateControllerFocus(-1, mControllerFocus);
break; break;
case SDL_CONTROLLER_BUTTON_DPAD_UP: case SDL_CONTROLLER_BUTTON_DPAD_UP:
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(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:
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(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:
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(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:
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(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)
@ -297,10 +289,8 @@ namespace MWGui
else else
mScrollView->setViewOffset(MyGUI::IntPoint(-42 * (column - 3), 0)); 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(); MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) winMgr->restoreControllerTooltips();
winMgr->setControllerTooltipVisible(true);
if (winMgr->getControllerTooltipVisible()) if (winMgr->getControllerTooltipVisible())
MWBase::Environment::get().getInputManager()->warpMouseToWidget(focused); MWBase::Environment::get().getInputManager()->warpMouseToWidget(focused);

View File

@ -248,9 +248,7 @@ namespace MWGui
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
{ {
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(true);
if (mSpellButtons.size() <= 1) if (mSpellButtons.size() <= 1)
return true; return true;
@ -261,9 +259,7 @@ namespace MWGui
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
{ {
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(true);
if (mSpellButtons.size() <= 1) if (mSpellButtons.size() <= 1)
return true; return true;

View File

@ -1058,7 +1058,7 @@ namespace MWGui
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK) else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK)
{ {
// Toggle info tooltip // Toggle info tooltip
winMgr->setControllerTooltipVisible(!mRightColumn && !winMgr->getControllerTooltipVisible()); winMgr->setControllerTooltipEnabled(!winMgr->getControllerTooltipEnabled());
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
{ {

View File

@ -367,27 +367,19 @@ namespace MWGui
winMgr->setControllerTooltipEnabled(!winMgr->getControllerTooltipEnabled()); winMgr->setControllerTooltipEnabled(!winMgr->getControllerTooltipEnabled());
break; break;
case SDL_CONTROLLER_BUTTON_DPAD_UP: case SDL_CONTROLLER_BUTTON_DPAD_UP:
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(true);
mControllerFocus--; mControllerFocus--;
break; break;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(true);
mControllerFocus++; mControllerFocus++;
break; break;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(true);
mControllerFocus = std::max(0, mControllerFocus - 10); mControllerFocus = std::max(0, mControllerFocus - 10);
break; break;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
// Restore tooltip visibility if user has them enabled but they were hidden by mouse winMgr->restoreControllerTooltips();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible())
winMgr->setControllerTooltipVisible(true);
mControllerFocus = std::min(mControllerFocus + 10, static_cast<int>(mButtons.size()) - 1); mControllerFocus = std::min(mControllerFocus + 10, static_cast<int>(mButtons.size()) - 1);
break; break;
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
@ -463,10 +455,8 @@ namespace MWGui
mScrollView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5))); 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(); MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
if (winMgr->getControllerTooltipEnabled() && !winMgr->getControllerTooltipVisible()) winMgr->restoreControllerTooltips();
winMgr->setControllerTooltipVisible(true);
if (winMgr->getControllerTooltipVisible()) if (winMgr->getControllerTooltipVisible())
MWBase::Environment::get().getInputManager()->warpMouseToWidget(focused); MWBase::Environment::get().getInputManager()->warpMouseToWidget(focused);

View File

@ -2660,6 +2660,13 @@ namespace MWGui
mControllerTooltipVisible = enabled; 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() void WindowManager::updateControllerButtonsOverlay()
{ {
if (!Settings::gui().mControllerMenus || !mControllerButtonsOverlay) if (!Settings::gui().mControllerMenus || !mControllerButtonsOverlay)

View File

@ -399,6 +399,7 @@ namespace MWGui
void setControllerTooltipVisible(bool visible) override; void setControllerTooltipVisible(bool visible) override;
bool getControllerTooltipEnabled() const override { return mControllerTooltipEnabled; } bool getControllerTooltipEnabled() const override { return mControllerTooltipEnabled; }
void setControllerTooltipEnabled(bool enabled) override; void setControllerTooltipEnabled(bool enabled) override;
void restoreControllerTooltips() override;
void updateControllerButtonsOverlay() override; void updateControllerButtonsOverlay() override;
// Used in Lua bindings // Used in Lua bindings