*/
#include "client/hud.h"
+#include <cmath>
#include "settings.h"
#include "util/numeric.h"
#include "log.h"
this->inventory = inventory;
m_hud_scaling = g_settings->getFloat("hud_scaling");
- m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE *
+ m_hotbar_imagesize = std::floor(HOTBAR_IMAGE_SIZE *
RenderingEngine::getDisplayDensity() + 0.5f);
m_hotbar_imagesize *= m_hud_scaling;
m_padding = m_hotbar_imagesize / 12;
case HUD_ELEM_WAYPOINT: {
v3f p_pos = player->getPosition() / BS;
v3f w_pos = e->world_pos * BS;
- float distance = floor(10 * p_pos.getDistanceFrom(e->world_pos)) / 10;
+ float distance = std::floor(10 * p_pos.getDistanceFrom(e->world_pos)) /
+ 10.0f;
scene::ICameraSceneNode* camera =
RenderingEngine::get_scene_manager()->getActiveCamera();
w_pos -= intToFloat(camera_offset, BS);
}
-void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture,
+void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, const std::string &texture,
s32 count, v2s32 offset, v2s32 size)
{
const video::SColor color(255, 255, 255, 255);
hotbar_itemcount / 2, mainlist, playeritem + 1, 0);
}
}
-
- //////////////////////////// compatibility code to be removed //////////////
- // this is ugly as hell but there's no other way to keep compatibility to
- // old servers
- if ((player->hud_flags & HUD_FLAG_HEALTHBAR_VISIBLE)) {
- drawStatbar(v2s32(floor(0.5 * (float)m_screensize.X + 0.5),
- floor(1 * (float) m_screensize.Y + 0.5)),
- HUD_CORNER_UPPER, 0, "heart.png",
- player->hp, v2s32((-10*24)-25,-(48+24+10)), v2s32(24,24));
- }
-
- if ((player->hud_flags & HUD_FLAG_BREATHBAR_VISIBLE) &&
- (player->getBreath() < 11)) {
- drawStatbar(v2s32(floor(0.5 * (float)m_screensize.X + 0.5),
- floor(1 * (float) m_screensize.Y + 0.5)),
- HUD_CORNER_UPPER, 0, "bubble.png",
- player->getBreath(), v2s32(25,-(48+24+10)), v2s32(24,24));
- }
- ////////////////////////////////////////////////////////////////////////////
}
// wear = 0.5: yellow
// wear = 1.0: red
video::SColor color(255,255,255,255);
- int wear_i = MYMIN(floor(wear * 600), 511);
+ int wear_i = MYMIN(std::floor(wear * 600), 511);
wear_i = MYMIN(wear_i + 10, 511);
- if(wear_i <= 255)
+ if (wear_i <= 255)
color.set(255, wear_i, 255, 0);
else
- color.set(255, 255, 511-wear_i, 0);
+ color.set(255, 255, 511 - wear_i, 0);
core::rect<s32> progressrect2 = progressrect;
progressrect2.LowerRightCorner.X = progressmid;