diff options
Diffstat (limited to 'src/hud.cpp')
-rw-r--r-- | src/hud.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/hud.cpp b/src/hud.cpp index 1b3b2f264..2285fb71e 100644 --- a/src/hud.cpp +++ b/src/hud.cpp @@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mesh.h" #include "wieldmesh.h" #include <IGUIStaticText.h> +#include "client/renderingengine.h" #ifdef HAVE_TOUCHSCREENGUI #include "touchscreengui.h" @@ -51,7 +52,8 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr, this->inventory = inventory; m_hud_scaling = g_settings->getFloat("hud_scaling"); - m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE * porting::getDisplayDensity() + 0.5); + m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE * + RenderingEngine::getDisplayDensity() + 0.5f); m_hotbar_imagesize *= m_hud_scaling; m_padding = m_hotbar_imagesize / 12; @@ -213,8 +215,8 @@ void Hud::drawItems(v2s32 upperleftpos, v2s32 screen_offset, s32 itemcount, // Position of upper left corner of bar v2s32 pos = screen_offset; - pos.X *= m_hud_scaling * porting::getDisplayDensity(); - pos.Y *= m_hud_scaling * porting::getDisplayDensity(); + pos.X *= m_hud_scaling * RenderingEngine::getDisplayDensity(); + pos.Y *= m_hud_scaling * RenderingEngine::getDisplayDensity(); pos += upperleftpos; // Store hotbar_image in member variable, used by drawItem() @@ -384,7 +386,7 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, if (size == v2s32()) { dstd = srcd; } else { - float size_factor = m_hud_scaling * porting::getDisplayDensity(); + float size_factor = m_hud_scaling * RenderingEngine::getDisplayDensity(); dstd.Height = size.Y * size_factor; dstd.Width = size.X * size_factor; offset.X *= size_factor; @@ -449,7 +451,8 @@ void Hud::drawHotbar(u16 playeritem) { s32 width = hotbar_itemcount * (m_hotbar_imagesize + m_padding * 2); v2s32 pos = centerlowerpos - v2s32(width / 2, m_hotbar_imagesize + m_padding * 3); - if ( (float) width / (float) porting::getWindowSize().X <= + const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize(); + if ( (float) width / (float) window_size.X <= g_settings->getFloat("hud_hotbar_max_width")) { if (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE) { drawItems(pos, v2s32(0, 0), hotbar_itemcount, 0, mainlist, playeritem + 1, 0); @@ -607,11 +610,14 @@ void Hud::updateSelectionMesh(const v3s16 &camera_offset) } void Hud::resizeHotbar() { - if (m_screensize != porting::getWindowSize()) { - m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE * porting::getDisplayDensity() + 0.5); + const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize(); + + if (m_screensize != window_size) { + m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE * + RenderingEngine::getDisplayDensity() + 0.5); m_hotbar_imagesize *= m_hud_scaling; m_padding = m_hotbar_imagesize / 12; - m_screensize = porting::getWindowSize(); + m_screensize = window_size; m_displaycenter = v2s32(m_screensize.X/2,m_screensize.Y/2); } } |