diff --git a/apps/openmw/mwgui/itemchargeview.cpp b/apps/openmw/mwgui/itemchargeview.cpp index abbf328a8c..4ac59642ea 100644 --- a/apps/openmw/mwgui/itemchargeview.cpp +++ b/apps/openmw/mwgui/itemchargeview.cpp @@ -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)); } } } diff --git a/apps/openmw/mwgui/merchantrepair.cpp b/apps/openmw/mwgui/merchantrepair.cpp index c720971c5b..c659cac139 100644 --- a/apps/openmw/mwgui/merchantrepair.cpp +++ b/apps/openmw/mwgui/merchantrepair.cpp @@ -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; diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 48d7134b8a..27065bc2c3 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -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; diff --git a/apps/openmw/mwgui/spellview.cpp b/apps/openmw/mwgui/spellview.cpp index e36a862730..8a18eb440f 100644 --- a/apps/openmw/mwgui/spellview.cpp +++ b/apps/openmw/mwgui/spellview.cpp @@ -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); } } }