From 0f2c3ecb17fa73de4cf2a83e3a94ac7899cb0f26 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 30 Jul 2018 16:42:45 +0400 Subject: [PATCH] Rescale player avatar (bug #4539) --- CHANGELOG.md | 1 + apps/openmw/mwgui/inventorywindow.cpp | 14 ++++++++++++-- apps/openmw/mwgui/inventorywindow.hpp | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5b62bf1a..31d9134e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ Bug #4503: Cast and ExplodeSpell commands increase alteration skill Bug #4510: Division by zero in MWMechanics::CreatureStats::setAttribute Bug #4519: Knockdown does not discard movement in the 1st-person mode + Bug #4539: Paper Doll is affected by GUI scaling Feature #2606: Editor: Implemented (optional) case sensitive global search Feature #3083: Play animation when NPC is casting spell via script Feature #3276: Editor: Search- Show number of (remaining) search results and indicate a search without any results diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index e909ecbba..ce6d0d522 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -67,7 +67,12 @@ namespace MWGui , mLastYSize(0) , mPreview(new MWRender::InventoryPreview(parent, resourceSystem, MWMechanics::getPlayer())) , mTrading(false) + , mScaleFactor(1.0f) { + float uiScale = Settings::Manager::getFloat("scaling factor", "GUI"); + if (uiScale > 1.0) + mScaleFactor = uiScale; + mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture())); mPreview->rebuild(); @@ -431,10 +436,10 @@ namespace MWGui MyGUI::IntSize size = mAvatarImage->getSize(); int width = std::min(mPreview->getTextureWidth(), size.width); int height = std::min(mPreview->getTextureHeight(), size.height); - mPreview->setViewport(width, height); + mPreview->setViewport(int(width*mScaleFactor), int(height*mScaleFactor)); mAvatarImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, - width/float(mPreview->getTextureWidth()), height/float(mPreview->getTextureHeight()))); + width*mScaleFactor/float(mPreview->getTextureWidth()), height*mScaleFactor/float(mPreview->getTextureHeight()))); } void InventoryWindow::onFilterChanged(MyGUI::Widget* _sender) @@ -591,6 +596,11 @@ namespace MWGui { // convert to OpenGL lower-left origin y = (mAvatarImage->getHeight()-1) - y; + + // Scale coordinates + x = int(x*mScaleFactor); + y = int(y*mScaleFactor); + int slot = mPreview->getSlotSelected (x, y); if (slot == -1) diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 124fe7b0e..d9cf6870c 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -101,6 +101,7 @@ namespace MWGui std::unique_ptr mPreview; bool mTrading; + float mScaleFactor; void onItemSelected(int index); void onItemSelectedFromSourceModel(int index);