mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-23 11:54:58 -04:00
Fix inventory menu getting messed up when resizing game window
This commit is contained in:
parent
5b5ed21f20
commit
fb19a0da91
@ -939,6 +939,24 @@ namespace MWGui
|
|||||||
setActiveControllerWindow(mode, activeIndex);
|
setActiveControllerWindow(mode, activeIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::reapplyActiveControllerWindow()
|
||||||
|
{
|
||||||
|
if (!Settings::gui().mControllerMenus || mGuiModes.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const GuiMode mode = mGuiModes.back();
|
||||||
|
int winCount = mGuiModeStates[mode].mWindows.size();
|
||||||
|
|
||||||
|
for (int i = 0; i < winCount; i++)
|
||||||
|
{
|
||||||
|
// Set active window last so inactive windows don't stomp on changes it makes, e.g. to tooltips.
|
||||||
|
if (i != mActiveControllerWindows[mode])
|
||||||
|
mGuiModeStates[mode].mWindows[i]->setActiveControllerWindow(false);
|
||||||
|
}
|
||||||
|
if (winCount > 0)
|
||||||
|
mGuiModeStates[mode].mWindows[mActiveControllerWindows[mode]]->setActiveControllerWindow(true);
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::setActiveControllerWindow(GuiMode mode, int activeIndex)
|
void WindowManager::setActiveControllerWindow(GuiMode mode, int activeIndex)
|
||||||
{
|
{
|
||||||
if (!Settings::gui().mControllerMenus)
|
if (!Settings::gui().mControllerMenus)
|
||||||
@ -951,13 +969,7 @@ namespace MWGui
|
|||||||
activeIndex = std::clamp(activeIndex, 0, winCount - 1);
|
activeIndex = std::clamp(activeIndex, 0, winCount - 1);
|
||||||
mActiveControllerWindows[mode] = activeIndex;
|
mActiveControllerWindows[mode] = activeIndex;
|
||||||
|
|
||||||
// Set active window last so inactive windows don't stomp on changes it makes, e.g. to tooltips.
|
reapplyActiveControllerWindow();
|
||||||
for (int i = 0; i < winCount; i++)
|
|
||||||
{
|
|
||||||
if (i != activeIndex)
|
|
||||||
mGuiModeStates[mode].mWindows[i]->setActiveControllerWindow(false);
|
|
||||||
}
|
|
||||||
mGuiModeStates[mode].mWindows[activeIndex]->setActiveControllerWindow(true);
|
|
||||||
|
|
||||||
MWBase::Environment::get().getInputManager()->setGamepadGuiCursorEnabled(
|
MWBase::Environment::get().getInputManager()->setGamepadGuiCursorEnabled(
|
||||||
mGuiModeStates[mode].mWindows[activeIndex]->isGamepadCursorAllowed());
|
mGuiModeStates[mode].mWindows[activeIndex]->isGamepadCursorAllowed());
|
||||||
@ -1331,6 +1343,9 @@ namespace MWGui
|
|||||||
for (const auto& window : mWindows)
|
for (const auto& window : mWindows)
|
||||||
window->onResChange(x, y);
|
window->onResChange(x, y);
|
||||||
|
|
||||||
|
// Re-apply any controller-specific window changes.
|
||||||
|
reapplyActiveControllerWindow();
|
||||||
|
|
||||||
// TODO: check if any windows are now off-screen and move them back if so
|
// TODO: check if any windows are now off-screen and move them back if so
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1478,18 +1493,7 @@ namespace MWGui
|
|||||||
if (mGuiModes.empty())
|
if (mGuiModes.empty())
|
||||||
setControllerTooltip(false);
|
setControllerTooltip(false);
|
||||||
else
|
else
|
||||||
{
|
reapplyActiveControllerWindow();
|
||||||
// Re-apply any controller-specific window changes.
|
|
||||||
const GuiMode mode = mGuiModes.back();
|
|
||||||
int winCount = mGuiModeStates[mode].mWindows.size();
|
|
||||||
|
|
||||||
for (int i = 0; i < winCount; i++)
|
|
||||||
{
|
|
||||||
if (i != mActiveControllerWindows[mode])
|
|
||||||
mGuiModeStates[mode].mWindows[i]->setActiveControllerWindow(false);
|
|
||||||
}
|
|
||||||
mGuiModeStates[mode].mWindows[mActiveControllerWindows[mode]]->setActiveControllerWindow(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,6 +515,8 @@ namespace MWGui
|
|||||||
std::map<GuiMode, int> mActiveControllerWindows;
|
std::map<GuiMode, int> mActiveControllerWindows;
|
||||||
bool mControllerTooltip;
|
bool mControllerTooltip;
|
||||||
|
|
||||||
|
void reapplyActiveControllerWindow();
|
||||||
|
|
||||||
std::unique_ptr<SDLUtil::SDLCursorManager> mCursorManager;
|
std::unique_ptr<SDLUtil::SDLCursorManager> mCursorManager;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Layout>> mGarbageDialogs;
|
std::vector<std::unique_ptr<Layout>> mGarbageDialogs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user