1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-13 16:13:06 +00:00

Fix not checking bounds in some controller menus

This commit is contained in:
Andrew Lanzone 2025-06-03 20:17:53 -07:00
parent a824993a60
commit ae676e1d70
4 changed files with 24 additions and 17 deletions

View file

@ -280,10 +280,10 @@ namespace MWGui
mLines[newFocus].mIcon->setControllerFocus(true); mLines[newFocus].mIcon->setControllerFocus(true);
// Scroll the list to keep the active item in view // Scroll the list to keep the active item in view
if (mControllerFocus <= 3) if (newFocus <= 3)
mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); mScrollView->setViewOffset(MyGUI::IntPoint(0, 0));
else else
mScrollView->setViewOffset(MyGUI::IntPoint(-55 * (mControllerFocus - 3), 0)); mScrollView->setViewOffset(MyGUI::IntPoint(-55 * (newFocus - 3), 0));
} }
} }
} }

View file

@ -205,6 +205,8 @@ namespace MWGui
} }
// Scroll the list to keep the active item in view // Scroll the list to keep the active item in view
if (mControllerFocus >= 0 && mControllerFocus < mButtons.size())
{
int line = mButtons[mControllerFocus].second; int line = mButtons[mControllerFocus].second;
if (line <= 5) if (line <= 5)
mList->setViewOffset(MyGUI::IntPoint(0, 0)); mList->setViewOffset(MyGUI::IntPoint(0, 0));
@ -213,6 +215,7 @@ namespace MWGui
const int lineHeight = Settings::gui().mFontSize + 2; const int lineHeight = Settings::gui().mFontSize + 2;
mList->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5))); mList->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5)));
} }
}
return true; return true;
} }

View file

@ -247,6 +247,8 @@ namespace MWGui
mSpellButtons[mControllerFocus].first->setStateSelected(true); mSpellButtons[mControllerFocus].first->setStateSelected(true);
} }
if (mControllerFocus >= 0 && mControllerFocus < mSpellButtons.size())
{
// Scroll the list to keep the active item in view // Scroll the list to keep the active item in view
int line = mSpellButtons[mControllerFocus].second; int line = mSpellButtons[mControllerFocus].second;
if (line <= 5) if (line <= 5)
@ -256,6 +258,7 @@ namespace MWGui
const int lineHeight = Settings::gui().mFontSize + 2; const int lineHeight = Settings::gui().mFontSize + 2;
mSpellsView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5))); mSpellsView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5)));
} }
}
return true; return true;
} }

View file

@ -408,8 +408,6 @@ namespace MWGui
if (focused) if (focused)
{ {
focused->onMouseSetFocus(nullptr); focused->onMouseSetFocus(nullptr);
if (mControllerTooltip)
MWBase::Environment::get().getInputManager()->warpMouseToWidget(focused);
// Scroll the list to keep the active item in view // Scroll the list to keep the active item in view
int line = mButtons[newFocus].second; int line = mButtons[newFocus].second;
@ -420,6 +418,9 @@ namespace MWGui
const int lineHeight = focused->getHeight(); const int lineHeight = focused->getHeight();
mScrollView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5))); mScrollView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5)));
} }
if (mControllerTooltip)
MWBase::Environment::get().getInputManager()->warpMouseToWidget(focused);
} }
} }
} }