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

Remove some hardcoded menu sizes for inventory mode

This commit is contained in:
Andrew Lanzone 2025-07-19 17:12:09 -07:00
parent f8d9149e4f
commit 29f1c7c68f
12 changed files with 50 additions and 10 deletions

View file

@ -387,6 +387,8 @@ namespace MWBase
/// Return the window that should receive controller events /// Return the window that should receive controller events
virtual MWGui::WindowBase* getActiveControllerWindow() = 0; virtual MWGui::WindowBase* getActiveControllerWindow() = 0;
/// Return the available height for menus accounting for visible controller overlays
virtual int getControllerMenuHeight() = 0;
/// Cycle to the next window to receive controller events /// Cycle to the next window to receive controller events
virtual void cycleActiveControllerWindow(bool next) = 0; virtual void cycleActiveControllerWindow(bool next) = 0;
virtual void setActiveControllerWindow(MWGui::GuiMode mode, int activeIndex) = 0; virtual void setActiveControllerWindow(MWGui::GuiMode mode, int activeIndex) = 0;

View file

@ -1,5 +1,7 @@
#include "controllerbuttonsoverlay.hpp" #include "controllerbuttonsoverlay.hpp"
#include <MyGUI_Window.h>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -37,6 +39,12 @@ namespace MWGui
getWidget(mHBox, "ButtonBox"); getWidget(mHBox, "ButtonBox");
} }
int ControllerButtonsOverlay::getHeight()
{
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>();
return window->getHeight();
}
void ControllerButtonsOverlay::setButtons(ControllerButtonStr* buttons) void ControllerButtonsOverlay::setButtons(ControllerButtonStr* buttons)
{ {
int buttonCount = 0; int buttonCount = 0;

View file

@ -15,6 +15,7 @@ namespace MWGui
public: public:
ControllerButtonsOverlay(); ControllerButtonsOverlay();
int getHeight();
void setButtons(ControllerButtonStr* buttons); void setButtons(ControllerButtonStr* buttons);
private: private:

View file

@ -1,6 +1,7 @@
#include "inventorytabsoverlay.hpp" #include "inventorytabsoverlay.hpp"
#include <MyGUI_ImageBox.h> #include <MyGUI_ImageBox.h>
#include <MyGUI_Window.h>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
@ -39,6 +40,12 @@ namespace MWGui
MWBase::Environment::get().getInputManager()->getControllerAxisIcon(SDL_CONTROLLER_AXIS_TRIGGERRIGHT)); MWBase::Environment::get().getInputManager()->getControllerAxisIcon(SDL_CONTROLLER_AXIS_TRIGGERRIGHT));
} }
int InventoryTabsOverlay::getHeight()
{
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>();
return window->getHeight();
}
void InventoryTabsOverlay::onTabClicked(MyGUI::Widget* sender) void InventoryTabsOverlay::onTabClicked(MyGUI::Widget* sender)
{ {
if (!MWBase::Environment::get().getWindowManager()->getJournalAllowed()) if (!MWBase::Environment::get().getWindowManager()->getJournalAllowed())

View file

@ -12,6 +12,7 @@ namespace MWGui
public: public:
InventoryTabsOverlay(); InventoryTabsOverlay();
int getHeight();
void setTab(int index); void setTab(int index);
private: private:

View file

@ -42,6 +42,7 @@
#include "itemview.hpp" #include "itemview.hpp"
#include "settings.hpp" #include "settings.hpp"
#include "sortfilteritemmodel.hpp" #include "sortfilteritemmodel.hpp"
#include "statswindow.hpp"
#include "tooltips.hpp" #include "tooltips.hpp"
#include "tradeitemmodel.hpp" #include "tradeitemmodel.hpp"
#include "tradewindow.hpp" #include "tradewindow.hpp"
@ -1109,13 +1110,14 @@ namespace MWGui
if (!Settings::gui().mControllerMenus) if (!Settings::gui().mControllerMenus)
return; return;
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Inventory) MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
if (winMgr->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.
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
int width = std::min(viewSize.width, 1600); int width = std::min(viewSize.width, 1600);
int height = std::min(viewSize.height - 48 - 48, 750); int height = std::min(winMgr->getControllerMenuHeight(), StatsWindow::getIdealHeight());
int x = (viewSize.width - width) / 2; int x = (viewSize.width - width) / 2;
int y = (viewSize.height - height) / 2; int y = (viewSize.height - height) / 2;

View file

@ -1440,13 +1440,14 @@ namespace MWGui
void MapWindow::setActiveControllerWindow(bool active) void MapWindow::setActiveControllerWindow(bool active)
{ {
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Inventory) MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
if (winMgr->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.
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
int width = std::min(viewSize.width, 1552); int width = std::min(viewSize.width, 1552);
int height = std::min(viewSize.height - 48 - 48, 1572); int height = std::min(winMgr->getControllerMenuHeight(), 1572);
int x = (viewSize.width - width) / 2; int x = (viewSize.width - width) / 2;
int y = (viewSize.height - height) / 2; int y = (viewSize.height - height) / 2;

View file

@ -29,6 +29,7 @@
#include "confirmationdialog.hpp" #include "confirmationdialog.hpp"
#include "spellicons.hpp" #include "spellicons.hpp"
#include "spellview.hpp" #include "spellview.hpp"
#include "statswindow.hpp"
namespace MWGui namespace MWGui
{ {
@ -313,13 +314,14 @@ namespace MWGui
void SpellWindow::setActiveControllerWindow(bool active) void SpellWindow::setActiveControllerWindow(bool active)
{ {
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Inventory) MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
if (winMgr->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.
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
int width = std::min(viewSize.width, 600); int width = std::min(viewSize.width, StatsWindow::getIdealWidth());
int height = std::min(viewSize.height - 48 - 48, 750); int height = std::min(winMgr->getControllerMenuHeight(), StatsWindow::getIdealHeight());
int x = (viewSize.width - width) / 2; int x = (viewSize.width - width) / 2;
int y = (viewSize.height - height) / 2; int y = (viewSize.height - height) / 2;

View file

@ -745,13 +745,14 @@ namespace MWGui
void StatsWindow::setActiveControllerWindow(bool active) void StatsWindow::setActiveControllerWindow(bool active)
{ {
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Inventory) MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
if (winMgr->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.
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
int width = std::min(viewSize.width, 600); int width = std::min(viewSize.width, getIdealWidth());
int height = std::min(viewSize.height - 48 - 48, 750); int height = std::min(winMgr->getControllerMenuHeight(), getIdealHeight());
int x = (viewSize.width - width) / 2; int x = (viewSize.width - width) / 2;
int y = (viewSize.height - height) / 2; int y = (viewSize.height - height) / 2;

View file

@ -13,6 +13,10 @@ namespace MWGui
public: public:
typedef std::map<ESM::RefId, int> FactionList; typedef std::map<ESM::RefId, int> FactionList;
/// It would be nice to measure these, but for now they're hardcoded.
static int getIdealHeight() { return 750; }
static int getIdealWidth() { return 600; }
StatsWindow(DragAndDrop* drag); StatsWindow(DragAndDrop* drag);
/// automatically updates all the data in the stats window, but only if it has changed. /// automatically updates all the data in the stats window, but only if it has changed.

View file

@ -2621,6 +2621,16 @@ namespace MWGui
return res; return res;
} }
int WindowManager::getControllerMenuHeight()
{
int height = MyGUI::RenderManager::getInstance().getViewSize().height;
if (mControllerButtonsOverlay != nullptr && mControllerButtonsOverlay->isVisible())
height -= mControllerButtonsOverlay->getHeight();
if (mInventoryTabsOverlay != nullptr && mInventoryTabsOverlay->isVisible())
height -= mInventoryTabsOverlay->getHeight();
return height;
}
void WindowManager::setControllerTooltip(bool enabled) void WindowManager::setControllerTooltip(bool enabled)
{ {
if (!Settings::gui().mControllerMenus) if (!Settings::gui().mControllerMenus)

View file

@ -394,6 +394,7 @@ namespace MWGui
void asyncPrepareSaveMap() override; void asyncPrepareSaveMap() override;
WindowBase* getActiveControllerWindow() override; WindowBase* getActiveControllerWindow() override;
int getControllerMenuHeight() override;
void cycleActiveControllerWindow(bool next) override; void cycleActiveControllerWindow(bool next) override;
void setActiveControllerWindow(GuiMode mode, int activeIndex) override; void setActiveControllerWindow(GuiMode mode, int activeIndex) override;
bool getControllerTooltip() const override { return mControllerTooltip; } bool getControllerTooltip() const override { return mControllerTooltip; }