Skip to content

Commit

Permalink
Merge pull request OpenMW#1021 from Allofich/weight
Browse files Browse the repository at this point in the history
Corrections to tooltip displays of zero-weight items
  • Loading branch information
scrawl authored Aug 14, 2016
2 parents 2f60753 + 7bf04b5 commit 8c44334
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/apparatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace MWClass

std::string text;
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
Expand Down
8 changes: 6 additions & 2 deletions apps/openmw/mwclass/armor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ namespace MWClass
typeText = "#{sLight}";
else if (armorType == ESM::Skill::MediumArmor)
typeText = "#{sMedium}";
else
else if (armorType == ESM::Skill::HeavyArmor)
typeText = "#{sHeavy}";
else // if (armorType == ESM::Skill::Unarmored)
typeText = "";

text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(getEffectiveArmorRating(ptr,
MWMechanics::getPlayer()));
Expand All @@ -236,7 +238,9 @@ namespace MWClass
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/"
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);

text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight) + " (" + typeText + ")";
if (typeText != "")
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight) + " (" + typeText + ")";

text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/book.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace MWClass

std::string text;

text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/clothing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace MWClass

std::string text;

text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/ingredient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace MWClass

std::string text;

text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
Expand Down
8 changes: 3 additions & 5 deletions apps/openmw/mwclass/light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,9 @@ namespace MWClass

if (Settings::Manager::getBool("show effect duration","Game"))
text += "\n#{sDuration}: " + MWGui::ToolTips::toString(ptr.getClass().getRemainingUsageTime(ptr));
if (ref->mBase->mData.mWeight != 0)
{
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
}

text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/lockpick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace MWClass

text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
Expand Down
4 changes: 1 addition & 3 deletions apps/openmw/mwclass/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,9 @@ namespace MWClass

std::string text;

text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
if (!gold && !ref->mBase->mData.mIsKey)
{
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
}

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace MWClass

text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/repair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace MWClass

text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwclass/weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ namespace MWClass
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
}

text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

info.enchant = ref->mBase->mEnchant;
Expand Down
8 changes: 8 additions & 0 deletions apps/openmw/mwgui/tooltips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions apps/openmw/mwgui/tooltips.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8c44334

Please sign in to comment.