diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 39bd577af..2de8e2bb3 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -29,7 +29,7 @@ using namespace Widgets; ContainerBase::ContainerBase(WindowManager& parWindowManager,DragAndDrop* dragAndDrop,std::string guiFile) : WindowBase(guiFile, parWindowManager), mDragAndDrop(dragAndDrop), - mFilter(MWWorld::ContainerStore::Type_All), + mFilter(ContainerBase::Filter_All), mContainer() { getWidget(mContainerWidget, "Items"); @@ -96,7 +96,7 @@ void ContainerBase::setName(std::string contName) adjustWindowCaption(); } -void ContainerBase::setFilter(int filter) +void ContainerBase::setFilter(ContainerBase::Filter filter) { mFilter = filter; drawItems(); @@ -124,10 +124,32 @@ void ContainerBase::drawItems() int index = 0; - for (MWWorld::ContainerStoreIterator iter (containerStore.begin(mFilter)); iter!=containerStore.end(); ++iter) + + bool onlyMagic = false; + int categories; + if (mFilter == Filter_All) + categories = MWWorld::ContainerStore::Type_All; + else if (mFilter == Filter_Weapon) + categories = MWWorld::ContainerStore::Type_Weapon; + else if (mFilter == Filter_Apparel) + categories = MWWorld::ContainerStore::Type_Clothing + MWWorld::ContainerStore::Type_Armor; + else if (mFilter == Filter_Magic) + { + categories = MWWorld::ContainerStore::Type_Clothing + MWWorld::ContainerStore::Type_Armor + + MWWorld::ContainerStore::Type_Weapon + MWWorld::ContainerStore::Type_Book + + MWWorld::ContainerStore::Type_Potion; + onlyMagic = true; + } + else if (mFilter == Filter_Misc) + { + categories = MWWorld::ContainerStore::Type_Miscellaneous + MWWorld::ContainerStore::Type_Book + + MWWorld::ContainerStore::Type_Ingredient; + } + + for (MWWorld::ContainerStoreIterator iter (containerStore.begin(categories)); iter!=containerStore.end(); ++iter) { index++; - if(iter->getRefData().getCount() > 0) + if(iter->getRefData().getCount() > 0 && !(onlyMagic && MWWorld::Class::get(*iter).getEnchantment(*iter) == "" && iter->getTypeName() != typeid(ESM::Potion).name())) { std::string path = std::string("icons\\"); path+=MWWorld::Class::get(*iter).getInventoryIcon(*iter); diff --git a/apps/openmw/mwgui/container.hpp b/apps/openmw/mwgui/container.hpp index a34d22c77..a8c12bb6a 100644 --- a/apps/openmw/mwgui/container.hpp +++ b/apps/openmw/mwgui/container.hpp @@ -50,9 +50,18 @@ namespace MWGui ContainerBase(WindowManager& parWindowManager, DragAndDrop* dragAndDrop, std::string guiFile); virtual ~ContainerBase(); + enum Filter + { + Filter_All = 0x01, + Filter_Weapon = 0x02, + Filter_Apparel = 0x03, + Filter_Magic = 0x04, + Filter_Misc = 0x05 + }; + void open(MWWorld::Ptr container); void setName(std::string contName); - void setFilter(int filter); ///< set category filter + void setFilter(Filter filter); ///< set category filter void Update(); protected: @@ -62,7 +71,7 @@ namespace MWGui DragAndDrop* mDragAndDrop; MWWorld::Ptr mContainer; - int mFilter; + Filter mFilter; void onSelectedItem(MyGUI::Widget* _sender); void onContainerClicked(MyGUI::Widget* _sender); diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index b85380968..738ab578a 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -25,11 +25,22 @@ namespace MWGui : ContainerBase(parWindowManager,dragAndDrop,"openmw_inventory_window_layout.xml") { static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize); + + getWidget(mAvatar, "Avatar"); + getWidget(mEncumbranceBar, "EncumbranceBar"); + getWidget(mEncumbranceText, "EncumbranceBarT"); + getWidget(mFilterAll, "AllButton"); + getWidget(mFilterWeapon, "WeaponButton"); + getWidget(mFilterApparel, "ApparelButton"); + getWidget(mFilterMagic, "MagicButton"); + getWidget(mFilterMisc, "MiscButton"); } void InventoryWindow::openInventory() { open(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); + + onWindowResize(static_cast(mMainWidget)); } void InventoryWindow::onWindowResize(MyGUI::Window* _sender) diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 813fc88ab..db105a2f8 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -29,6 +29,17 @@ namespace MWGui void openInventory(); protected: + MyGUI::Widget* mAvatar; + MyGUI::TextBox* mArmorRating; + MyGUI::ProgressBar* mEncumbranceBar; + MyGUI::TextBox* mEncumbranceText; + + MyGUI::Button* mFilterAll; + MyGUI::Button* mFilterWeapon; + MyGUI::Button* mFilterApparel; + MyGUI::Button* mFilterMagic; + MyGUI::Button* mFilterMisc; + void onWindowResize(MyGUI::Window* _sender); }; } diff --git a/files/mygui/openmw_container_window_layout.xml b/files/mygui/openmw_container_window_layout.xml index 26fe0a3d3..7b14f5b58 100644 --- a/files/mygui/openmw_container_window_layout.xml +++ b/files/mygui/openmw_container_window_layout.xml @@ -5,9 +5,9 @@ - + - + diff --git a/files/mygui/openmw_inventory_window_layout.xml b/files/mygui/openmw_inventory_window_layout.xml index a347a510e..b2b32ea2c 100644 --- a/files/mygui/openmw_inventory_window_layout.xml +++ b/files/mygui/openmw_inventory_window_layout.xml @@ -4,30 +4,36 @@ - - + + + + + + - - + + + + - - + + - + - - - - - - + + + + + +