Hud: Modify Y-positioning of health/breath starbars to prevent overlapping with Hotbar

This commit is contained in:
kwolekr 2015-02-08 12:45:19 -05:00
parent a0535d286b
commit 15c037614f
2 changed files with 31 additions and 33 deletions

View File

@ -7,7 +7,7 @@ local health_bar_definition =
number = 20,
direction = 0,
size = { x=24, y=24 },
offset = { x=(-10*24)-25, y=-(48+24+10)},
offset = { x=(-10*24)-25, y=-(48+24+16)},
}
local breath_bar_definition =
@ -18,7 +18,7 @@ local breath_bar_definition =
number = 20,
direction = 0,
size = { x=24, y=24 },
offset = {x=25,y=-(48+24+10)},
offset = {x=25,y=-(48+24+16)},
}
local hud_ids = {}

View File

@ -341,16 +341,12 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture,
if (size == v2s32()) {
dstd = srcd;
} else {
dstd.Height = size.Y * g_settings->getFloat("hud_scaling") *
porting::getDisplayDensity();
dstd.Width = size.X * g_settings->getFloat("hud_scaling") *
porting::getDisplayDensity();
offset.X *= g_settings->getFloat("hud_scaling") *
porting::getDisplayDensity();
offset.Y *= g_settings->getFloat("hud_scaling") *
double size_factor = g_settings->getFloat("hud_scaling") *
porting::getDisplayDensity();
dstd.Height = size.Y * size_factor;
dstd.Width = size.X * size_factor;
offset.X *= size_factor;
offset.Y *= size_factor;
}
v2s32 p = pos;
@ -432,18 +428,20 @@ void Hud::drawHotbar(u16 playeritem) {
//////////////////////////// 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)
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))
(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, "heart.png",
HUD_CORNER_UPPER, 0, "bubble.png",
player->getBreath(), v2s32(25,-(48+24+10)), v2s32(24,24));
}
////////////////////////////////////////////////////////////////////////////
}