1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-09 18:34:37 +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);
// Scroll the list to keep the active item in view
if (mControllerFocus <= 3)
if (newFocus <= 3)
mScrollView->setViewOffset(MyGUI::IntPoint(0, 0));
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
int line = mButtons[mControllerFocus].second;
if (line <= 5)
mList->setViewOffset(MyGUI::IntPoint(0, 0));
else
if (mControllerFocus >= 0 && mControllerFocus < mButtons.size())
{
const int lineHeight = Settings::gui().mFontSize + 2;
mList->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5)));
int line = mButtons[mControllerFocus].second;
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;

View file

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

View file

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