aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlockMen <nmuelll@web.de>2013-09-19 20:39:19 +0200
committerKahrl <kahrl@gmx.net>2013-09-20 20:03:58 +0200
commit27947d85f7543a16a6c70aff4e9dcdca814c40ba (patch)
tree604f8684ece07f5fff939c3ffaf50dfb0bc65228 /src
parentf7ee5da4c115231df3f4897db04fd308749efe55 (diff)
downloadminetest-27947d85f7543a16a6c70aff4e9dcdca814c40ba.tar.gz
minetest-27947d85f7543a16a6c70aff4e9dcdca814c40ba.tar.bz2
minetest-27947d85f7543a16a6c70aff4e9dcdca814c40ba.zip
Add option to scale image to percentage values
Diffstat (limited to 'src')
-rw-r--r--src/hud.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/hud.cpp b/src/hud.cpp
index a0086b2f7..183f94e49 100644
--- a/src/hud.cpp
+++ b/src/hud.cpp
@@ -234,13 +234,16 @@ void Hud::drawLuaElements() {
const video::SColor color(255, 255, 255, 255);
const video::SColor colors[] = {color, color, color, color};
core::dimension2di imgsize(texture->getOriginalSize());
- core::rect<s32> rect(0, 0, imgsize.Width * e->scale.X,
- imgsize.Height * e->scale.X);
- rect += pos;
- v2s32 offset((e->align.X - 1.0) * ((imgsize.Width * e->scale.X) / 2),
- (e->align.Y - 1.0) * ((imgsize.Height * e->scale.X) / 2));
- rect += offset;
- rect += v2s32(e->offset.X, e->offset.Y);
+ v2s32 dstsize(imgsize.Width * e->scale.X,
+ imgsize.Height * e->scale.Y);
+ if (e->scale.X < 0)
+ dstsize.X = screensize.X * (e->scale.X * -0.01);
+ if (e->scale.Y < 0)
+ dstsize.Y = screensize.Y * (e->scale.Y * -0.01);
+ v2s32 offset((e->align.X - 1.0) * dstsize.X / 2,
+ (e->align.Y - 1.0) * dstsize.Y / 2);
+ core::rect<s32> rect(0, 0, dstsize.X, dstsize.Y);
+ rect += pos + offset + v2s32(e->offset.X, e->offset.Y);
driver->draw2DImage(texture, rect,
core::rect<s32>(core::position2d<s32>(0,0), imgsize),
NULL, colors, true);