1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-02 07:21:07 +00:00

Check if current weapon has health at all in HUD (bug )

This commit is contained in:
Andrei Kortunov 2018-09-22 06:51:56 +04:00
parent 7be9f2ca45
commit b3fd173e00
2 changed files with 6 additions and 2 deletions

@ -125,6 +125,7 @@
Bug #4633: Sneaking stance affects speed even if the actor is not able to crouch Bug #4633: Sneaking stance affects speed even if the actor is not able to crouch
Bug #4641: GetPCJumping is handled incorrectly Bug #4641: GetPCJumping is handled incorrectly
Bug #4644: %Name should be available for all actors, not just for NPCs Bug #4644: %Name should be available for all actors, not just for NPCs
Bug #4648: Hud thinks that throwing weapons have condition
Feature #912: Editor: Add missing icons to UniversalId tables Feature #912: Editor: Add missing icons to UniversalId tables
Feature #1617: Editor: Enchantment effect record verifier Feature #1617: Editor: Enchantment effect record verifier
Feature #1645: Casting effects from objects Feature #1645: Casting effects from objects

@ -1383,8 +1383,11 @@ namespace MWGui
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item) void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
{ {
mSelectedWeapon = item; mSelectedWeapon = item;
int durabilityPercent = int durabilityPercent = 100;
static_cast<int>(item.getClass().getItemHealth(item) / static_cast<float>(item.getClass().getItemMaxHealth(item)) * 100); if (item.getClass().hasItemHealth(item))
{
durabilityPercent = static_cast<int>(item.getClass().getItemHealth(item) / static_cast<float>(item.getClass().getItemMaxHealth(item)) * 100);
}
mHud->setSelectedWeapon(item, durabilityPercent); mHud->setSelectedWeapon(item, durabilityPercent);
mInventoryWindow->setTitle(item.getClass().getName(item)); mInventoryWindow->setTitle(item.getClass().getName(item));
} }