Use float based scale factor for ImageButton texture

post_malone
elsid 3 years ago
parent 3ba39f977b
commit a16c55c93f
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -131,6 +131,7 @@
Bug #6753: Info records without a DATA subrecords are loaded incorrectly
Bug #6794: Light sources are attached to mesh bounds centers instead of mesh origins when AttachLight NiNode is missing
Bug #6799: Game crashes if an NPC has no Class attached
Bug #6849: ImageButton texture is not scaled properly
Feature #890: OpenMW-CS: Column filtering
Feature #1465: "Reset" argument for AI functions
Feature #2491: Ability to make OpenMW "portable"

@ -1,5 +1,7 @@
#include "imagebutton.hpp"
#include <cmath>
#include <MyGUI_RenderManager.h>
#include <components/debug/debuglog.hpp>
@ -88,13 +90,17 @@ namespace Gui
if (!mUseWholeTexture)
{
int scale = 1.f;
float scale = 1.f;
MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(textureName);
if (texture && getHeight() != 0)
scale = texture->getHeight() / getHeight();
setImageTile(MyGUI::IntSize(mTextureRect.width * scale, mTextureRect.height * scale));
MyGUI::IntCoord scaledSize(mTextureRect.left * scale, mTextureRect.top * scale, mTextureRect.width * scale, mTextureRect.height * scale);
scale = static_cast<float>(texture->getHeight()) / getHeight();
const int width = static_cast<int>(std::round(mTextureRect.width * scale));
const int height = static_cast<int>(std::round(mTextureRect.height * scale));
setImageTile(MyGUI::IntSize(width, height));
MyGUI::IntCoord scaledSize(static_cast<int>(std::round(mTextureRect.left * scale)),
static_cast<int>(std::round(mTextureRect.top * scale)),
width, height);
setImageCoord(scaledSize);
}

Loading…
Cancel
Save