mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
a8650e785d
commit
b3a36f7378
50 changed files with 1568 additions and 1567 deletions
22
src/hud.cpp
22
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue