forked from mirror/openmw-tes3mp
Display remaining item health / enchantment charge in HUD icons, display remaining enchanment charge in tooltips
This commit is contained in:
parent
8ca88d1a70
commit
43cdbd033d
11 changed files with 25 additions and 11 deletions
|
@ -182,8 +182,8 @@ namespace MWBase
|
|||
virtual void activateQuickKey (int index) = 0;
|
||||
|
||||
virtual void setSelectedSpell(const std::string& spellId, int successChancePercent) = 0;
|
||||
virtual void setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) = 0;
|
||||
virtual void setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent) = 0;
|
||||
virtual void setSelectedEnchantItem(const MWWorld::Ptr& item) = 0;
|
||||
virtual void setSelectedWeapon(const MWWorld::Ptr& item) = 0;
|
||||
virtual void unsetSelectedSpell() = 0;
|
||||
virtual void unsetSelectedWeapon() = 0;
|
||||
|
||||
|
|
|
@ -260,6 +260,8 @@ namespace MWClass
|
|||
}
|
||||
|
||||
info.enchant = ref->mBase->mEnchant;
|
||||
if (!info.enchant.empty())
|
||||
info.remainingEnchantCharge = ptr.getCellRef().mEnchantmentCharge;
|
||||
|
||||
info.text = text;
|
||||
|
||||
|
|
|
@ -207,6 +207,8 @@ namespace MWClass
|
|||
}
|
||||
|
||||
info.enchant = ref->mBase->mEnchant;
|
||||
if (!info.enchant.empty())
|
||||
info.remainingEnchantCharge = ptr.getCellRef().mEnchantmentCharge;
|
||||
|
||||
info.text = text;
|
||||
|
||||
|
|
|
@ -349,6 +349,9 @@ namespace MWClass
|
|||
|
||||
info.enchant = ref->mBase->mEnchant;
|
||||
|
||||
if (!info.enchant.empty())
|
||||
info.remainingEnchantCharge = ptr.getCellRef().mEnchantmentCharge;
|
||||
|
||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||
|
|
|
@ -294,7 +294,7 @@ namespace MWGui
|
|||
if (weaponSlot == invStore.end())
|
||||
mWindowManager.unsetSelectedWeapon();
|
||||
else
|
||||
mWindowManager.setSelectedWeapon(*weaponSlot, 100); /// \todo track weapon durability
|
||||
mWindowManager.setSelectedWeapon(*weaponSlot); /// \todo track weapon durability
|
||||
|
||||
mPreviewDirty = true;
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ namespace MWGui
|
|||
|
||||
store.setSelectedEnchantItem(it);
|
||||
spells.setSelectedSpell("");
|
||||
mWindowManager.setSelectedEnchantItem(item, 100); /// \todo track charge %
|
||||
mWindowManager.setSelectedEnchantItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ namespace MWGui
|
|||
|
||||
store.setSelectedEnchantItem(it);
|
||||
spells.setSelectedSpell("");
|
||||
mWindowManager.setSelectedEnchantItem(item, 100); /// \todo track charge %
|
||||
mWindowManager.setSelectedEnchantItem(item);
|
||||
|
||||
updateSpells();
|
||||
}
|
||||
|
|
|
@ -456,8 +456,8 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
if (enchant->mData.mType == ESM::Enchantment::WhenStrikes
|
||||
|| enchant->mData.mType == ESM::Enchantment::WhenUsed)
|
||||
{
|
||||
/// \todo store the current enchantment charge somewhere
|
||||
int charge = enchant->mData.mCharge;
|
||||
int maxCharge = enchant->mData.mCharge;
|
||||
int charge = (info.remainingEnchantCharge == -1) ? maxCharge : info.remainingEnchantCharge;
|
||||
|
||||
const int chargeWidth = 204;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace MWGui
|
|||
: isPotion(false)
|
||||
, imageSize(32)
|
||||
, wordWrap(true)
|
||||
, remainingEnchantCharge(-1)
|
||||
{}
|
||||
|
||||
std::string caption;
|
||||
|
@ -26,6 +27,7 @@ namespace MWGui
|
|||
|
||||
// enchantment (for cloth, armor, weapons)
|
||||
std::string enchant;
|
||||
int remainingEnchantCharge;
|
||||
|
||||
// effects (for potions, ingredients)
|
||||
Widgets::SpellEffectList effects;
|
||||
|
|
|
@ -933,14 +933,19 @@ void WindowManager::setSelectedSpell(const std::string& spellId, int successChan
|
|||
mSpellWindow->setTitle(spell->mName);
|
||||
}
|
||||
|
||||
void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
|
||||
void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item)
|
||||
{
|
||||
const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>()
|
||||
.find(MWWorld::Class::get(item).getEnchantment(item));
|
||||
|
||||
int chargePercent = item.getCellRef().mEnchantmentCharge / static_cast<float>(ench->mData.mCharge) * 100;
|
||||
mHud->setSelectedEnchantItem(item, chargePercent);
|
||||
mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item));
|
||||
}
|
||||
|
||||
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
|
||||
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
|
||||
{
|
||||
int durabilityPercent = item.getCellRef().mCharge / static_cast<float>(MWWorld::Class::get(item).getItemMaxHealth(item)) * 100;
|
||||
mHud->setSelectedWeapon(item, durabilityPercent);
|
||||
mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item));
|
||||
}
|
||||
|
|
|
@ -179,8 +179,8 @@ namespace MWGui
|
|||
virtual void activateQuickKey (int index);
|
||||
|
||||
virtual void setSelectedSpell(const std::string& spellId, int successChancePercent);
|
||||
virtual void setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent);
|
||||
virtual void setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent);
|
||||
virtual void setSelectedEnchantItem(const MWWorld::Ptr& item);
|
||||
virtual void setSelectedWeapon(const MWWorld::Ptr& item);
|
||||
virtual void unsetSelectedSpell();
|
||||
virtual void unsetSelectedWeapon();
|
||||
|
||||
|
|
Loading…
Reference in a new issue