mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-01 13:20:29 +00:00
Fixes #1204: Any health value < 1 should show as empty life bar.
This commit is contained in:
parent
93c21b5ef2
commit
61955111f1
@ -604,15 +604,22 @@ namespace MWGui
|
|||||||
mEffectBox->setPosition((viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop());
|
mEffectBox->setPosition((viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HUD::updateEnemyHealthBar()
|
||||||
|
{
|
||||||
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(mEnemy).getCreatureStats(mEnemy);
|
||||||
|
mEnemyHealth->setProgressRange(100);
|
||||||
|
// Health is usually cast to int before displaying. Actors die whenever they are < 1 health.
|
||||||
|
// Therefore any value < 1 should show as an empty health bar. We do the same in statswindow :)
|
||||||
|
mEnemyHealth->setProgressPosition(int(stats.getHealth().getCurrent()) / stats.getHealth().getModified() * 100);
|
||||||
|
}
|
||||||
|
|
||||||
void HUD::update()
|
void HUD::update()
|
||||||
{
|
{
|
||||||
mSpellIcons->updateWidgets(mEffectBox, true);
|
mSpellIcons->updateWidgets(mEffectBox, true);
|
||||||
|
|
||||||
if (!mEnemy.isEmpty() && mEnemyHealth->getVisible())
|
if (!mEnemy.isEmpty() && mEnemyHealth->getVisible())
|
||||||
{
|
{
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(mEnemy).getCreatureStats(mEnemy);
|
updateEnemyHealthBar();
|
||||||
mEnemyHealth->setProgressRange(100);
|
|
||||||
mEnemyHealth->setProgressPosition(stats.getHealth().getCurrent() / stats.getHealth().getModified() * 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsDrowning)
|
if (mIsDrowning)
|
||||||
@ -629,9 +636,7 @@ namespace MWGui
|
|||||||
if (!mEnemyHealth->getVisible())
|
if (!mEnemyHealth->getVisible())
|
||||||
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() - MyGUI::IntPoint(0,20));
|
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() - MyGUI::IntPoint(0,20));
|
||||||
mEnemyHealth->setVisible(true);
|
mEnemyHealth->setVisible(true);
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(mEnemy).getCreatureStats(mEnemy);
|
updateEnemyHealthBar();
|
||||||
mEnemyHealth->setProgressRange(100);
|
|
||||||
mEnemyHealth->setProgressPosition(stats.getHealth().getCurrent() / stats.getHealth().getModified() * 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,8 @@ namespace MWGui
|
|||||||
void onMagicClicked(MyGUI::Widget* _sender);
|
void onMagicClicked(MyGUI::Widget* _sender);
|
||||||
void onMapClicked(MyGUI::Widget* _sender);
|
void onMapClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
|
void updateEnemyHealthBar();
|
||||||
|
|
||||||
void updatePositions();
|
void updatePositions();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user