1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-11 14:04:30 +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,13 +205,16 @@ namespace MWGui
} }
// Scroll the list to keep the active item in view // Scroll the list to keep the active item in view
int line = mButtons[mControllerFocus].second; if (mControllerFocus >= 0 && mControllerFocus < mButtons.size())
if (line <= 5)
mList->setViewOffset(MyGUI::IntPoint(0, 0));
else
{ {
const int lineHeight = Settings::gui().mFontSize + 2; int line = mButtons[mControllerFocus].second;
mList->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5))); if (line <= 5)
mList->setViewOffset(MyGUI::IntPoint(0, 0));
else
{
const int lineHeight = Settings::gui().mFontSize + 2;
mList->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5)));
}
} }
return true; return true;

View file

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