revised filters

actorid
scrawl 13 years ago
parent 8e6c943400
commit 0114bf948c

@ -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);

@ -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);

@ -25,11 +25,22 @@ namespace MWGui
: ContainerBase(parWindowManager,dragAndDrop,"openmw_inventory_window_layout.xml")
{
static_cast<MyGUI::Window*>(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<MyGUI::Window*>(mMainWidget));
}
void InventoryWindow::onWindowResize(MyGUI::Window* _sender)

@ -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);
};
}

@ -5,9 +5,9 @@
<!-- Items -->
<Widget type="Widget" skin="MW_Box" position="5 5 575 225" name="box" align="Left Top Stretch">
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 571 221" name="ItemView" align="Left Top Stretch">
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 567 221" name="ItemView" align="Left Top Stretch">
<Property key="CanvasSize" value="1024 1024"/>
<Widget type="Button" skin="" name="Items" position="0 0 571 221" name="Items" align="Left Top Stretch"/>
<Widget type="Button" skin="" name="Items" position="0 0 567 221" name="Items" align="Left Top Stretch"/>
</Widget>
</Widget>

@ -4,30 +4,36 @@
<Widget type="Window" skin="MW_Window" layer="Windows" position="0 0 600 300" name="_Main">
<!-- Player encumbrance -->
<Widget type="ProgressBar" skin="MW_Progress_Blue" position="8 8 212 18" name="EncumbranceBar">
<Widget type="TextBox" skin="ProgressText" position="0 0 212 18" align="Center" name="EncumbranceBarT"/>
<Widget type="ProgressBar" skin="MW_Progress_Blue" position="8 8 212 24" name="EncumbranceBar">
<Property key="Range" value="100"/>
<Property key="RangePosition" value="50"/>
<Widget type="TextBox" skin="ProgressText" position="0 0 212 24" align="Center" name="EncumbranceBarT">
<Property key="Caption" value="Encumbrance bar"/>
</Widget>
</Widget>
<!-- Avatar -->
<Widget type="Widget" skin="MW_Box" position="8 32 212 166" name="Avatar">
<Widget type="TextBox" skin="ProgressText" position="0 -8 212 18" align="HCenter Bottom" name="ArmorRating"/>
<Widget type="Widget" skin="MW_Box" position="8 38 212 219" name="Avatar" align="Left Top VStretch">
<Widget type="TextBox" skin="ProgressText" position="0 180 212 24" align="HCenter Bottom" name="ArmorRating">
<Property key="Caption" value="Armor Rating goes here"/>
</Widget>
</Widget>
<!-- Items in inventory -->
<Widget type="Widget" skin="MW_Box" position="228 32 300 215" name="box" align="Left Top Stretch">
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 296 211" align="Left Top Stretch" name="ItemView">
<Widget type="Widget" skin="MW_Box" position="228 38 300 219" name="box" align="Left Top Stretch">
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 292 215" align="Left Top Stretch" name="ItemView">
<Property key="CanvasSize" value="1024 1024"/>
<Widget type="Button" skin="" name="Items" position="0 0 296 211" name="Items" align="Left Top Stretch"/>
<Widget type="Button" skin="" name="Items" position="0 0 292 215" name="Items" align="Left Top Stretch"/>
</Widget>
</Widget>
<!-- Categories -->
<Widget type="Widget" position="228 8 300 18" align="ALIGN_TOP ALIGN_LEFT" name="Categories">
<Widget type="Button" skin="MW_Button" position="0 0 30 18" name="AllButton"/>
<Widget type="Button" skin="MW_Button" position="134 0 60 18" name="WeaponButton"/>
<Widget type="Button" skin="MW_Button" position="98 0 60 18" name="ApparelButton"/>
<Widget type="Button" skin="MW_Button" position="160 0 50 18" name="MagicButton"/>
<Widget type="Button" skin="MW_Button" position="214 0 45 18" name="MiscButton"/>
<Widget type="Widget" position="228 8 300 24" align="ALIGN_TOP ALIGN_LEFT" name="Categories">
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="AllButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="WeaponButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="ApparelButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="MagicButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="MiscButton"/>
</Widget>
</Widget>

Loading…
Cancel
Save