diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 7a3d5b240..2defad207 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -16,6 +16,7 @@ #include "../mwclass/container.hpp" #include "../mwworld/containerstore.hpp" #include +#include "../mwworld/class.hpp" using namespace MWGui; @@ -101,49 +102,7 @@ void ContainerWindow::open(MWWorld::Ptr& container) std::string path = std::string("icons\\"); - //path += iter.getInventoryIcon(); - switch (iter.getType()) - { - - case MWWorld::ContainerStore::Type_Potion: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Apparatus: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Armor: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Book: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Clothing: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Ingredient: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Light: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Lockpick: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Miscellaneous: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Probe: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Repair: - path += iter->get()->base->icon; - break; - case MWWorld::ContainerStore::Type_Weapon: - path += iter->get()->base->icon; - break; - - - } + path+=MWWorld::Class::get(*iter).getInventoryIcon(*iter); count++; if(count % 8 == 0) diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index d49b98d0f..2dd8aee1e 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -173,4 +173,9 @@ namespace MWWorld { throw std::runtime_error ("class does not have an down sound"); } + + std::string Class::getInventoryIcon (const MWWorld::Ptr& ptr) const + { + throw std::runtime_error ("class does not have any inventory icon"); + } } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index e474e9b92..eaa0d5f6f 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -174,6 +174,9 @@ namespace MWWorld virtual std::string getDownSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const; ///< Return the down sound ID of \a ptr or throw an exception, if class does not support ID retrieval /// (default implementation: throw an exception) + + virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const; + ///< Return name of inventory icon. }; } diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 3f1b7ea2c..86ee15e58 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -456,34 +456,4 @@ bool MWWorld::operator== (const ContainerStoreIterator& left, const ContainerSto bool MWWorld::operator!= (const ContainerStoreIterator& left, const ContainerStoreIterator& right) { return !(left==right); -} - - -std::string MWWorld::ContainerStoreIterator::getInventoryIcon() -{ - Ptr ptr; - - switch (mType) - { - case ContainerStore::Type_Potion: ptr = MWWorld::Ptr (&*mPotion, 0); break; - case ContainerStore::Type_Apparatus: ptr = MWWorld::Ptr (&*mApparatus, 0); break; - case ContainerStore::Type_Armor: ptr = MWWorld::Ptr (&*mArmor, 0); break; - case ContainerStore::Type_Book: ptr = MWWorld::Ptr (&*mBook, 0); break; - case ContainerStore::Type_Clothing: ptr = MWWorld::Ptr (&*mClothing, 0); break; - case ContainerStore::Type_Ingredient: ptr = MWWorld::Ptr (&*mIngredient, 0); break; - case ContainerStore::Type_Light: ptr = MWWorld::Ptr (&*mLight, 0); break; - case ContainerStore::Type_Lockpick: ptr = MWWorld::Ptr (&*mLockpick, 0); break; - case ContainerStore::Type_Miscellaneous: ptr = MWWorld::Ptr (&*mMiscellaneous, 0); break; - case ContainerStore::Type_Probe: ptr = MWWorld::Ptr (&*mProbe, 0); break; - case ContainerStore::Type_Repair: ptr = MWWorld::Ptr (&*mRepair, 0); break; - case ContainerStore::Type_Weapon: ptr = MWWorld::Ptr (&*mWeapon, 0); break; - } - - if (ptr.isEmpty()) - throw std::runtime_error ("invalid iterator"); - - - std::string s = "";//ptr.getInventoryIcon(); - - return s; -} +} \ No newline at end of file diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index fc6283442..da5424fe0 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -161,8 +161,6 @@ namespace MWWorld const ContainerStore *getContainerStore() const; - std::string getInventoryIcon(); - friend class ContainerStore; }; diff --git a/files/mygui/core.xml b/files/mygui/core.xml index 7417328cf..8e256ca9c 100644 --- a/files/mygui/core.xml +++ b/files/mygui/core.xml @@ -20,6 +20,7 @@ +