mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Item search in inventory (feature #4831)
This commit is contained in:
parent
b1acb9e467
commit
78d58a344d
@ -225,6 +225,7 @@
|
||||
Feature #4730: Native animated containers support
|
||||
Feature #4784: Launcher: Duplicate Content Lists
|
||||
Feature #4812: Support NiSwitchNode
|
||||
Feature #4831: Item search in the player's inventory
|
||||
Feature #4836: Daytime node switch
|
||||
Feature #4840: Editor: Transient terrain change support
|
||||
Feature #4859: Make water reflections more configurable
|
||||
|
@ -46,9 +46,11 @@ CompanionWindow::CompanionWindow(DragAndDrop *dragAndDrop, MessageBoxManager* ma
|
||||
getWidget(mCloseButton, "CloseButton");
|
||||
getWidget(mProfitLabel, "ProfitLabel");
|
||||
getWidget(mEncumbranceBar, "EncumbranceBar");
|
||||
getWidget(mFilterEdit, "FilterEdit");
|
||||
getWidget(mItemView, "ItemView");
|
||||
mItemView->eventBackgroundClicked += MyGUI::newDelegate(this, &CompanionWindow::onBackgroundSelected);
|
||||
mItemView->eventItemClicked += MyGUI::newDelegate(this, &CompanionWindow::onItemSelected);
|
||||
mFilterEdit->eventEditTextChange += MyGUI::newDelegate(this, &CompanionWindow::onNameFilterChanged);
|
||||
|
||||
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CompanionWindow::onCloseButtonClicked);
|
||||
|
||||
@ -92,6 +94,12 @@ void CompanionWindow::onItemSelected(int index)
|
||||
dragItem (nullptr, count);
|
||||
}
|
||||
|
||||
void CompanionWindow::onNameFilterChanged(MyGUI::EditBox* _sender)
|
||||
{
|
||||
mSortModel->setNameFilter(_sender->getCaption());
|
||||
mItemView->update();
|
||||
}
|
||||
|
||||
void CompanionWindow::dragItem(MyGUI::Widget* sender, int count)
|
||||
{
|
||||
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count);
|
||||
|
@ -39,11 +39,13 @@ namespace MWGui
|
||||
DragAndDrop* mDragAndDrop;
|
||||
|
||||
MyGUI::Button* mCloseButton;
|
||||
MyGUI::EditBox* mFilterEdit;
|
||||
MyGUI::TextBox* mProfitLabel;
|
||||
Widgets::MWDynamicStat* mEncumbranceBar;
|
||||
MessageBoxManager* mMessageBoxManager;
|
||||
|
||||
void onItemSelected(int index);
|
||||
void onNameFilterChanged(MyGUI::EditBox* _sender);
|
||||
void onBackgroundSelected();
|
||||
void dragItem(MyGUI::Widget* sender, int count);
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <MyGUI_RenderManager.h>
|
||||
#include <MyGUI_InputManager.h>
|
||||
#include <MyGUI_Button.h>
|
||||
#include <MyGUI_EditBox.h>
|
||||
|
||||
#include <osg/Texture2D>
|
||||
|
||||
@ -90,6 +91,7 @@ namespace MWGui
|
||||
getWidget(mLeftPane, "LeftPane");
|
||||
getWidget(mRightPane, "RightPane");
|
||||
getWidget(mArmorRating, "ArmorRating");
|
||||
getWidget(mFilterEdit, "FilterEdit");
|
||||
|
||||
mAvatarImage->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onAvatarClicked);
|
||||
mAvatarImage->setRenderItemTexture(mPreviewTexture.get());
|
||||
@ -104,6 +106,7 @@ namespace MWGui
|
||||
mFilterApparel->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
|
||||
mFilterMagic->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
|
||||
mFilterMisc->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
|
||||
mFilterEdit->eventEditTextChange += MyGUI::newDelegate(this, &InventoryWindow::onNameFilterChanged);
|
||||
|
||||
mFilterAll->setStateSelected(true);
|
||||
|
||||
@ -388,6 +391,11 @@ namespace MWGui
|
||||
|
||||
void InventoryWindow::onOpen()
|
||||
{
|
||||
// Reset the filter focus when opening the window
|
||||
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||
if (focus == mFilterEdit)
|
||||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(nullptr);
|
||||
|
||||
if (!mPtr.isEmpty())
|
||||
{
|
||||
updateEncumbranceBar();
|
||||
@ -465,6 +473,12 @@ namespace MWGui
|
||||
width*mScaleFactor/float(mPreview->getTextureWidth()), height*mScaleFactor/float(mPreview->getTextureHeight())));
|
||||
}
|
||||
|
||||
void InventoryWindow::onNameFilterChanged(MyGUI::EditBox* _sender)
|
||||
{
|
||||
mSortModel->setNameFilter(_sender->getCaption());
|
||||
mItemView->update();
|
||||
}
|
||||
|
||||
void InventoryWindow::onFilterChanged(MyGUI::Widget* _sender)
|
||||
{
|
||||
if (_sender == mFilterAll)
|
||||
@ -477,7 +491,6 @@ namespace MWGui
|
||||
mSortModel->setCategory(SortFilterItemModel::Category_Magic);
|
||||
else if (_sender == mFilterMisc)
|
||||
mSortModel->setCategory(SortFilterItemModel::Category_Misc);
|
||||
|
||||
mFilterAll->setStateSelected(false);
|
||||
mFilterWeapon->setStateSelected(false);
|
||||
mFilterApparel->setStateSelected(false);
|
||||
|
@ -92,6 +92,8 @@ namespace MWGui
|
||||
MyGUI::Button* mFilterApparel;
|
||||
MyGUI::Button* mFilterMagic;
|
||||
MyGUI::Button* mFilterMisc;
|
||||
|
||||
MyGUI::EditBox* mFilterEdit;
|
||||
|
||||
MWWorld::Ptr mSkippedToEquip;
|
||||
|
||||
@ -121,6 +123,7 @@ namespace MWGui
|
||||
|
||||
void onWindowResize(MyGUI::Window* _sender);
|
||||
void onFilterChanged(MyGUI::Widget* _sender);
|
||||
void onNameFilterChanged(MyGUI::EditBox* _sender);
|
||||
void onAvatarClicked(MyGUI::Widget* _sender);
|
||||
void onPinToggled();
|
||||
|
||||
|
@ -250,6 +250,10 @@ namespace MWGui
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string compare = Misc::StringUtils::lowerCase(item.mBase.getClass().getName(item.mBase));
|
||||
if(compare.find(mNameFilter) == std::string::npos)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -277,6 +281,11 @@ namespace MWGui
|
||||
mFilter = filter;
|
||||
}
|
||||
|
||||
void SortFilterItemModel::setNameFilter (const std::string& filter)
|
||||
{
|
||||
mNameFilter = Misc::StringUtils::lowerCase(filter);
|
||||
}
|
||||
|
||||
void SortFilterItemModel::update()
|
||||
{
|
||||
mSourceModel->update();
|
||||
|
@ -25,6 +25,7 @@ namespace MWGui
|
||||
|
||||
void setCategory (int category);
|
||||
void setFilter (int filter);
|
||||
void setNameFilter (const std::string& filter);
|
||||
|
||||
/// Use ItemStack::Type for sorting?
|
||||
void setSortByType(bool sort) { mSortByType = sort; }
|
||||
@ -57,6 +58,8 @@ namespace MWGui
|
||||
int mCategory;
|
||||
int mFilter;
|
||||
bool mSortByType;
|
||||
|
||||
std::string mNameFilter; // filter by item name
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ namespace MWGui
|
||||
getWidget(mTotalBalance, "TotalBalance");
|
||||
getWidget(mTotalBalanceLabel, "TotalBalanceLabel");
|
||||
getWidget(mBottomPane, "BottomPane");
|
||||
getWidget(mFilterEdit, "FilterEdit");
|
||||
|
||||
getWidget(mItemView, "ItemView");
|
||||
mItemView->eventItemClicked += MyGUI::newDelegate(this, &TradeWindow::onItemSelected);
|
||||
@ -80,6 +81,7 @@ namespace MWGui
|
||||
mFilterApparel->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onFilterChanged);
|
||||
mFilterMagic->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onFilterChanged);
|
||||
mFilterMisc->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onFilterChanged);
|
||||
mFilterEdit->eventEditTextChange += MyGUI::newDelegate(this, &TradeWindow::onNameFilterChanged);
|
||||
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked);
|
||||
mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked);
|
||||
@ -135,8 +137,7 @@ namespace MWGui
|
||||
setTitle(actor.getClass().getName(actor));
|
||||
|
||||
onFilterChanged(mFilterAll);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTotalBalance);
|
||||
mFilterEdit->setCaption("");
|
||||
}
|
||||
|
||||
void TradeWindow::onFrame(float dt)
|
||||
@ -144,6 +145,12 @@ namespace MWGui
|
||||
checkReferenceAvailable();
|
||||
}
|
||||
|
||||
void TradeWindow::onNameFilterChanged(MyGUI::EditBox* _sender)
|
||||
{
|
||||
mSortModel->setNameFilter(_sender->getCaption());
|
||||
mItemView->update();
|
||||
}
|
||||
|
||||
void TradeWindow::onFilterChanged(MyGUI::Widget* _sender)
|
||||
{
|
||||
if (_sender == mFilterAll)
|
||||
|
@ -59,6 +59,8 @@ namespace MWGui
|
||||
MyGUI::Button* mFilterMagic;
|
||||
MyGUI::Button* mFilterMisc;
|
||||
|
||||
MyGUI::EditBox* mFilterEdit;
|
||||
|
||||
MyGUI::Button* mIncreaseButton;
|
||||
MyGUI::Button* mDecreaseButton;
|
||||
MyGUI::TextBox* mTotalBalanceLabel;
|
||||
@ -86,6 +88,7 @@ namespace MWGui
|
||||
void sellItem (MyGUI::Widget* sender, int count);
|
||||
|
||||
void onFilterChanged(MyGUI::Widget* _sender);
|
||||
void onNameFilterChanged(MyGUI::EditBox* _sender);
|
||||
void onOfferButtonClicked(MyGUI::Widget* _sender);
|
||||
void onAccept(MyGUI::EditBox* sender);
|
||||
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||
|
@ -4,8 +4,14 @@
|
||||
<Widget type="Window" skin="MW_Window" layer="Windows" position="0 0 600 300" name="_Main">
|
||||
<Property key="MinSize" value="245 145"/>
|
||||
|
||||
<!-- Search box-->
|
||||
<Widget type="HBox" position="5 5 575 23" align="Left Top HStretch" name="_Filter">
|
||||
<Widget type="EditBox" skin="MW_TextBoxEditWithBorder" position="0 0 0 23" name="FilterEdit">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<!-- Items -->
|
||||
<Widget type="ItemView" skin="MW_ItemView" position="5 5 575 225" name="ItemView" align="Left Top Stretch">
|
||||
<Widget type="ItemView" skin="MW_ItemView" position="5 33 575 197" name="ItemView" align="Left Top Stretch">
|
||||
</Widget>
|
||||
|
||||
<Widget type="HBox" position="5 235 575 24" align="Bottom HStretch">
|
||||
|
@ -50,6 +50,10 @@
|
||||
<Property key="Caption" value="#{sMiscTab}"/>
|
||||
<Property key="NeedKey" value="false"/>
|
||||
</Widget>
|
||||
<!-- Search box-->
|
||||
<Widget type="EditBox" skin="MW_TextBoxEditWithBorder" position="0 0 0 23" name="FilterEdit">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
|
@ -27,6 +27,10 @@
|
||||
<Property key="Caption" value="#{sMiscTab}"/>
|
||||
<Property key="NeedKey" value="false"/>
|
||||
</Widget>
|
||||
<!-- Search box-->
|
||||
<Widget type="EditBox" skin="MW_TextBoxEditWithBorder" position="0 0 0 23" name="FilterEdit">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Items -->
|
||||
|
Loading…
Reference in New Issue
Block a user