summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-09 00:47:31 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-09 00:47:57 +0300
commite72f26151bca6c5a73d0377e385c0f7dd7cab3aa (patch)
tree6960f1846e0258a5f3658cae6e2f40f643074e3f /src/gui/widgets
parentf1c17766c66394ce875854430f8f028c0fa5b3a5 (diff)
downloadManaVerse-e72f26151bca6c5a73d0377e385c0f7dd7cab3aa.tar.gz
ManaVerse-e72f26151bca6c5a73d0377e385c0f7dd7cab3aa.tar.bz2
ManaVerse-e72f26151bca6c5a73d0377e385c0f7dd7cab3aa.tar.xz
ManaVerse-e72f26151bca6c5a73d0377e385c0f7dd7cab3aa.zip
Add to inventory filter by letters from item names.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/itemcontainer.cpp13
-rw-r--r--src/gui/widgets/itemcontainer.h4
-rw-r--r--src/gui/widgets/textfield.cpp13
-rw-r--r--src/gui/widgets/textfield.h3
4 files changed, 28 insertions, 5 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 75968d668..84313d64f 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -513,6 +513,9 @@ void ItemContainer::updateMatrix()
int i = 0;
int j = 0;
+ std::string temp = mName;
+ toLower(temp);
+
for (unsigned idx = 0; idx < mInventory->getSize(); idx ++)
{
Item *item = mInventory->getItem(idx);
@@ -520,7 +523,15 @@ void ItemContainer::updateMatrix()
if (!item || item->getId() == 0 || !item->isHaveTag(mTag))
continue;
- sortedItems.push_back(new ItemIdPair(idx, item));
+ if (mName.empty())
+ {
+ sortedItems.push_back(new ItemIdPair(idx, item));
+ continue;
+ }
+ std::string name = item->getInfo().getName();
+ toLower(name);
+ if (name.find(temp) != std::string::npos)
+ sortedItems.push_back(new ItemIdPair(idx, item));
}
switch (mSortType)
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index df7de63ee..845bfb3a9 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -125,6 +125,9 @@ class ItemContainer : public gcn::Widget,
void setSortType (int sortType);
+ void setName(std::string str)
+ { mName = str; }
+
void updateMatrix();
private:
@@ -194,6 +197,7 @@ class ItemContainer : public gcn::Widget,
int mDragPosX, mDragPosY;
int mTag;
int mSortType;
+ std::string mName;
ItemPopup *mItemPopup;
int *mShowMatrix;
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index d9f5bed9a..5d4fbc0b4 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -48,12 +48,14 @@ float TextField::mAlpha = 1.0;
ImageRect TextField::skin;
TextField::TextField(const std::string &text, bool loseFocusOnTab,
- gcn::ActionListener* listener, std::string eventId):
+ gcn::ActionListener* listener, std::string eventId,
+ bool sendAlwaysEvents):
gcn::TextField(text),
mNumeric(false),
mMinimum(0),
mMaximum(0),
- mLastEventPaste(false)
+ mLastEventPaste(false),
+ mSendAlwaysEvents(sendAlwaysEvents)
{
setFrameSize(2);
@@ -276,7 +278,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
case Key::ENTER:
distributeActionEvent();
- break;
+ keyEvent.consume();
+ fixScroll();
+ return;
case Key::HOME:
mCaretPosition = 0;
@@ -337,6 +341,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
break;
}
+ if (mSendAlwaysEvents)
+ distributeActionEvent();
+
keyEvent.consume();
fixScroll();
}
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index 79790d83a..7e19099e8 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -41,7 +41,7 @@ class TextField : public gcn::TextField
*/
TextField(const std::string &text = "", bool loseFocusOnTab = true,
gcn::ActionListener* listener = NULL,
- std::string eventId = "");
+ std::string eventId = "", bool sendAlwaysEvents = false);
~TextField();
@@ -109,6 +109,7 @@ class TextField : public gcn::TextField
int mMaximum;
bool mLoseFocusOnTab;
int mLastEventPaste;
+ bool mSendAlwaysEvents;
};
#endif