summaryrefslogtreecommitdiff
path: root/src/hud.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-06-26 20:11:17 +0200
committerGitHub <noreply@github.com>2017-06-26 20:11:17 +0200
commitb3a36f7378ea0f299cfa36c81de42e00adb7292d (patch)
tree23d056b575ff0dba8cc759cc00f732099a1f3bce /src/hud.cpp
parenta8650e785df3f12efa5f8cd3c6a695fb9e22a598 (diff)
downloadminetest-b3a36f7378ea0f299cfa36c81de42e00adb7292d.tar.gz
minetest-b3a36f7378ea0f299cfa36c81de42e00adb7292d.tar.bz2
minetest-b3a36f7378ea0f299cfa36c81de42e00adb7292d.zip
Isolate irrlicht references and use a singleton (#6041)
* Add Device3D class which will contain IrrlichtDevice interface move getSupportedVideoDrivers to Device3D Add Device3D singleton & use it in various places Rename Device3D to Rendering engine & add helper functions to various device pointers More singleton work RenderingEngine owns draw_load_screen move draw functions to RenderingEngine Reduce IrrlichtDevice exposure and guienvironment RenderingEngine: Expose get_timer_time() to remove device from guiEngine Make irrlichtdevice & scene manager less exposed * Code style fixes * Move porting::getVideoDriverName, getVideoDriverFriendlyName, getDisplayDensity, getDisplaySize to RenderingEngine Fix XORG_USED macro -> RenderingEngine + create_engine_device from RenderingEngine constructor directly * enum paralax => enum parallax
Diffstat (limited to 'src/hud.cpp')
-rw-r--r--src/hud.cpp22
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);
}
}