1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-23 00:56:39 +00:00

Allow pinning map window in controller mode

This commit is contained in:
Andrew Lanzone 2025-05-25 16:12:19 -07:00
parent 45de167b6b
commit d6ed416402
5 changed files with 83 additions and 46 deletions

View file

@ -216,7 +216,7 @@ namespace MWGui
{ {
mGuiMode = mode; mGuiMode = mode;
const WindowSettingValues settings = getModeSettings(mGuiMode); const WindowSettingValues settings = getModeSettings(mGuiMode);
setPinButtonVisible(mode == GM_Inventory); setPinButtonVisible(mode == GM_Inventory && !Settings::gui().mControllerMenus);
const WindowRectSettingValues& rect = settings.mIsMaximized ? settings.mMaximized : settings.mRegular; const WindowRectSettingValues& rect = settings.mIsMaximized ? settings.mMaximized : settings.mRegular;

View file

@ -1029,7 +1029,20 @@ namespace MWGui
void MapWindow::setVisible(bool visible) void MapWindow::setVisible(bool visible)
{ {
WindowBase::setVisible(visible); WindowBase::setVisible(visible);
mButton->setVisible(visible && MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_None); MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
mButton->setVisible(visible && mode != MWGui::GM_None);
if (Settings::gui().mControllerMenus && mode == MWGui::GM_None && pinned() && visible)
{
// Restore the window to pinned size.
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>();
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
const float x = Settings::windows().mMapX * viewSize.width;
const float y = Settings::windows().mMapY * viewSize.height;
const float w = Settings::windows().mMapW * viewSize.width;
const float h = Settings::windows().mMapH * viewSize.height;
window->setCoord(x, y, w, h);
}
} }
void MapWindow::renderGlobalMap() void MapWindow::renderGlobalMap()
@ -1435,6 +1448,8 @@ namespace MWGui
} }
void MapWindow::setActiveControllerWindow(bool active) void MapWindow::setActiveControllerWindow(bool active)
{
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Inventory)
{ {
// Fill the screen, or limit to a certain size on large screens. Size chosen to // Fill the screen, or limit to a certain size on large screens. Size chosen to
// show the entire local map without scrolling. // show the entire local map without scrolling.
@ -1446,6 +1461,7 @@ namespace MWGui
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>(); MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>();
window->setCoord(x, active ? y : viewSize.height + 1, width, height); window->setCoord(x, active ? y : viewSize.height + 1, width, height);
}
WindowBase::setActiveControllerWindow(active); WindowBase::setActiveControllerWindow(active);
} }

View file

@ -60,6 +60,7 @@ namespace MWGui
if (Settings::gui().mControllerMenus) if (Settings::gui().mControllerMenus)
{ {
setPinButtonVisible(false);
mControllerButtons.a = "#{sSelect}"; mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sBack}"; mControllerButtons.b = "#{sBack}";
mControllerButtons.r3 = "#{sInfo}"; mControllerButtons.r3 = "#{sInfo}";
@ -280,6 +281,8 @@ namespace MWGui
} }
void SpellWindow::setActiveControllerWindow(bool active) void SpellWindow::setActiveControllerWindow(bool active)
{
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Inventory)
{ {
// Fill the screen, or limit to a certain size on large screens. Size chosen to // Fill the screen, or limit to a certain size on large screens. Size chosen to
// match the size of the stats window. // match the size of the stats window.
@ -291,6 +294,7 @@ namespace MWGui
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>(); MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>();
window->setCoord(x, active ? y : viewSize.height + 1, width, height); window->setCoord(x, active ? y : viewSize.height + 1, width, height);
}
if (active) if (active)
mSpellView->update(); mSpellView->update();

View file

@ -83,6 +83,7 @@ namespace MWGui
if (Settings::gui().mControllerMenus) if (Settings::gui().mControllerMenus)
{ {
setPinButtonVisible(false);
mControllerButtons.lStick = "#{sInfo}"; mControllerButtons.lStick = "#{sInfo}";
mControllerButtons.rStick = "#{sScrolldown}"; mControllerButtons.rStick = "#{sScrolldown}";
mControllerButtons.b = "#{sBack}"; mControllerButtons.b = "#{sBack}";
@ -741,6 +742,8 @@ namespace MWGui
} }
void StatsWindow::setActiveControllerWindow(bool active) void StatsWindow::setActiveControllerWindow(bool active)
{
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Inventory)
{ {
// Fill the screen, or limit to a certain size on large screens. Size chosen to // Fill the screen, or limit to a certain size on large screens. Size chosen to
// show all stats. // show all stats.
@ -755,6 +758,7 @@ namespace MWGui
if (active) if (active)
onWindowResize(window); onWindowResize(window);
}
WindowBase::setActiveControllerWindow(active); WindowBase::setActiveControllerWindow(active);
} }

View file

@ -1901,6 +1901,11 @@ namespace MWGui
void WindowManager::onWindowChangeCoord(MyGUI::Window* window) void WindowManager::onWindowChangeCoord(MyGUI::Window* window)
{ {
// If using controller menus, don't persist changes to size of the stats or magic
// windows.
if (Settings::gui().mControllerMenus && (window == (MyGUI::Window*)mStatsWindow || window == (MyGUI::Window*)mSpellWindow))
return;
const auto it = mTrackedWindows.find(window); const auto it = mTrackedWindows.find(window);
if (it == mTrackedWindows.end()) if (it == mTrackedWindows.end())
return; return;
@ -2147,24 +2152,32 @@ namespace MWGui
void WindowManager::updatePinnedWindows() void WindowManager::updatePinnedWindows()
{ {
mInventoryWindow->setPinned(Settings::windows().mInventoryPin); if (Settings::gui().mControllerMenus)
mMap->setPinned(Settings::windows().mMapPin);
mSpellWindow->setPinned(Settings::windows().mSpellsPin);
mStatsWindow->setPinned(Settings::windows().mStatsPin);
// Hide hidden inventory windows, but not in controller mode.
if (!Settings::gui().mControllerMenus)
{ {
// In controller mode, don't hide any menus and only allow pinning the map.
mInventoryWindow->setPinned(false);
mMap->setPinned(Settings::windows().mMapPin);
mSpellWindow->setPinned(false);
mStatsWindow->setPinned(false);
return;
}
mInventoryWindow->setPinned(Settings::windows().mInventoryPin);
if (Settings::windows().mInventoryHidden) if (Settings::windows().mInventoryHidden)
mShown = (GuiWindow)(mShown ^ GW_Inventory); mShown = (GuiWindow)(mShown ^ GW_Inventory);
mMap->setPinned(Settings::windows().mMapPin);
if (Settings::windows().mMapHidden) if (Settings::windows().mMapHidden)
mShown = (GuiWindow)(mShown ^ GW_Map); mShown = (GuiWindow)(mShown ^ GW_Map);
mSpellWindow->setPinned(Settings::windows().mSpellsPin);
if (Settings::windows().mSpellsHidden) if (Settings::windows().mSpellsHidden)
mShown = (GuiWindow)(mShown ^ GW_Magic); mShown = (GuiWindow)(mShown ^ GW_Magic);
mStatsWindow->setPinned(Settings::windows().mStatsPin);
if (Settings::windows().mStatsHidden) if (Settings::windows().mStatsHidden)
mShown = (GuiWindow)(mShown ^ GW_Stats); mShown = (GuiWindow)(mShown ^ GW_Stats);
} }
}
void WindowManager::pinWindow(GuiWindow window) void WindowManager::pinWindow(GuiWindow window)
{ {