Screenshot:
Code:
Code: Select all
diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp
index 47dfa27b3..363bfbfce 100644
--- a/apps/openmw/mwclass/container.cpp
+++ b/apps/openmw/mwclass/container.cpp
@@ -209,6 +209,16 @@ namespace MWClass
return ptr.getRefData().getCustomData()->asContainerCustomData().mContainerStore;
}
+ const MWWorld::ContainerStore* Container::getConstContainerStore (const MWWorld::ConstPtr& ptr)
+ const
+ {
+ const ContainerCustomData* customData = dynamic_cast<const ContainerCustomData*>
+ (ptr.getRefData().getCustomData());
+ if (!customData)
+ return nullptr;
+ return &customData->mContainerStore;
+ }
+
std::string Container::getScript (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
@@ -246,6 +256,10 @@ namespace MWClass
if (ptr.getCellRef().getTrap() != "")
text += "\n#{sTrapped}";
+ const MWWorld::ContainerStore* containerStore = getConstContainerStore (ptr);
+ if (containerStore && lockLevel <= 0 && containerStore->isEmpty())
+ text += "\n[empty]";
+
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp
index e38d98b5c..1ea264563 100644
--- a/apps/openmw/mwclass/container.hpp
+++ b/apps/openmw/mwclass/container.hpp
@@ -34,6 +34,7 @@ namespace MWClass
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const;
+ virtual const MWWorld::ContainerStore* getConstContainerStore (const MWWorld::ConstPtr& ptr) const;
///< Return container store
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp
index 6725fb935..0ac6efc50 100644
--- a/apps/openmw/mwworld/containerstore.cpp
+++ b/apps/openmw/mwworld/containerstore.cpp
@@ -39,6 +39,20 @@ namespace
return sum;
}
+ template<typename T>
+ bool isEmpty (const MWWorld::CellRefList<T>& cellRefList)
+ {
+ for (typename MWWorld::CellRefList<T>::List::const_iterator iter (
+ cellRefList.mList.begin());
+ iter!=cellRefList.mList.end();
+ ++iter)
+ {
+ if (iter->mData.getCount()>0)
+ return false;
+ }
+ return true;
+ }
+
template<typename T>
MWWorld::Ptr searchId (MWWorld::CellRefList<T>& list, const std::string& id,
MWWorld::ContainerStore *store)
@@ -635,6 +649,23 @@ float MWWorld::ContainerStore::getWeight() const
return mCachedWeight;
}
+bool MWWorld::ContainerStore::isEmpty() const
+{
+ return
+ ::isEmpty (potions) &&
+ ::isEmpty (appas) &&
+ ::isEmpty (armors) &&
+ ::isEmpty (books) &&
+ ::isEmpty (clothes) &&
+ ::isEmpty (ingreds) &&
+ ::isEmpty (lights) &&
+ ::isEmpty (lockpicks) &&
+ ::isEmpty (miscItems) &&
+ ::isEmpty (probes) &&
+ ::isEmpty (repairs) &&
+ ::isEmpty (weapons);
+}
+
int MWWorld::ContainerStore::getType (const ConstPtr& ptr)
{
if (ptr.isEmpty())
diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp
index 4564d2fa3..a61b0ddbe 100644
--- a/apps/openmw/mwworld/containerstore.hpp
+++ b/apps/openmw/mwworld/containerstore.hpp
@@ -195,6 +195,8 @@ namespace MWWorld
float getWeight() const;
///< Return total weight of the items contained in *this.
+ bool isEmpty() const;
+
static int getType (const ConstPtr& ptr);
///< This function throws an exception, if ptr does not point to an object, that can be
/// put into a container.