Use getWeightString() to avoid casting to int

coverity_scan^2
Allofich 8 years ago
parent 4f5d676b4e
commit 502a26a7ff

@ -112,7 +112,7 @@ namespace MWClass
std::string text;
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {

@ -126,7 +126,7 @@ namespace MWClass
std::string text;
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {

@ -175,7 +175,7 @@ namespace MWClass
std::string text;
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {

@ -125,7 +125,7 @@ namespace MWClass
std::string text;
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {

@ -126,7 +126,7 @@ namespace MWClass
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {

@ -159,7 +159,7 @@ namespace MWClass
std::string text;
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
if (!gold && !ref->mBase->mData.mIsKey)
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");

@ -126,7 +126,7 @@ namespace MWClass
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {

@ -129,7 +129,7 @@ namespace MWClass
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {

@ -318,7 +318,7 @@ namespace MWClass
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
}
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
info.enchant = ref->mBase->mEnchant;

@ -586,6 +586,14 @@ namespace MWGui
return stream.str();
}
std::string ToolTips::getWeightString(const float weight, const std::string& prefix)
{
if (weight == 0)
return "";
else
return "\n" + prefix + ": " + toString(weight);
}
std::string ToolTips::getValueString(const int value, const std::string& prefix)
{
if (value == 0)

@ -62,6 +62,7 @@ namespace MWGui
void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
///< set the screen-space position of the tooltip for focused object
static std::string getWeightString(const float weight, const std::string& prefix);
static std::string getValueString(const int value, const std::string& prefix);
///< @return "prefix: value" or "" if value is 0

Loading…
Cancel
Save