mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-25 16:46:17 +00:00
Added: Text search to inventory
--HG-- branch : develop
This commit is contained in:
parent
455a923031
commit
7350291a56
4 changed files with 88 additions and 1 deletions
|
@ -549,7 +549,7 @@
|
|||
pop_min_h="240"
|
||||
pop_max_w="920"
|
||||
pop_max_h="1600"
|
||||
w="300"
|
||||
w="400"
|
||||
h="400"
|
||||
movable="true"
|
||||
active="false"
|
||||
|
|
|
@ -6589,6 +6589,18 @@
|
|||
dblink="UI:SAVE:#inv_type:FILTER_ARMOR"
|
||||
texture="filter_armor.tga"
|
||||
tooltip="uittFilterArmor" />
|
||||
<instance template="edit_box_widget"
|
||||
id="inv_query_eb"
|
||||
posref="BR BR"
|
||||
x="-190"
|
||||
y="1"
|
||||
w="100"
|
||||
clear_on_escape="true"
|
||||
enter_recover_focus="false"
|
||||
max_num_chars="20"
|
||||
max_historic="0"
|
||||
onenter="inv_set_search"
|
||||
onchange="inv_set_search" onchange_params="#inv_type" />
|
||||
<!-- details -->
|
||||
<instance template="tinv_item_list_icon_swap"
|
||||
id="detail"
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
// For handlers
|
||||
#include "nel/gui/action_handler.h"
|
||||
#include "nel/gui/group_editbox.h"
|
||||
#include "dbctrl_sheet.h"
|
||||
|
||||
#include "../sheet_manager.h"
|
||||
|
@ -2010,6 +2011,18 @@ bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */)
|
|||
return true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void SBagOptions::setSearchFilter(const ucstring &s)
|
||||
{
|
||||
SearchFilter.clear();
|
||||
SearchFilterChanged = true;
|
||||
|
||||
if (!s.empty())
|
||||
{
|
||||
splitUCString(toLower(s), ucstring(" "), SearchFilter);
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool SBagOptions::isSomethingChanged()
|
||||
{
|
||||
|
@ -2057,6 +2070,12 @@ bool SBagOptions::isSomethingChanged()
|
|||
LastDbFilterTP = (DbFilterTP->getValue8() != 0);
|
||||
}
|
||||
|
||||
if (SearchFilterChanged)
|
||||
{
|
||||
bRet = true;
|
||||
SearchFilterChanged = false;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
@ -2075,6 +2094,26 @@ bool SBagOptions::canDisplay(CDBCtrlSheet *pCS) const
|
|||
const CItemSheet *pIS = pCS->asItemSheet();
|
||||
if (pIS != NULL)
|
||||
{
|
||||
if (SearchFilter.size() > 0)
|
||||
{
|
||||
bool match = true;
|
||||
ucstring lcName = toLower(pCS->getItemActualName());
|
||||
|
||||
// add item quality as a keyword to match
|
||||
if (pCS->getQuality() > 1)
|
||||
{
|
||||
lcName += ucstring(" " + toString(pCS->getQuality()));
|
||||
}
|
||||
|
||||
for (uint i = 0; i< SearchFilter.size(); ++i)
|
||||
{
|
||||
if (lcName.find(SearchFilter[i]) == ucstring::npos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Armor
|
||||
if ((pIS->Family == ITEMFAMILY::ARMOR) ||
|
||||
(pIS->Family == ITEMFAMILY::JEWELRY))
|
||||
|
@ -2455,6 +2494,30 @@ class CHandlerInvDrag : public IActionHandler
|
|||
};
|
||||
REGISTER_ACTION_HANDLER( CHandlerInvDrag, "inv_drag" );
|
||||
|
||||
// **********************************************************************************************************
|
||||
class CHandlerInvSetSearch : public IActionHandler
|
||||
{
|
||||
void execute (CCtrlBase *pCaller, const std::string &sParams)
|
||||
{
|
||||
if (!pCaller) return;
|
||||
|
||||
CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(pCaller);
|
||||
if (!eb) return;
|
||||
|
||||
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
|
||||
// ui:interface:inventory:content:bag:iil:inv_query_eb:eb
|
||||
string invId = pCaller->getParent()->getParent()->getId();
|
||||
|
||||
CDBGroupListSheetBag *pList = dynamic_cast<CDBGroupListSheetBag*>(CWidgetManager::getInstance()->getElementFromId(invId + ":bag_list"));
|
||||
if (pList != NULL) pList->setSearchFilter(eb->getInputString());
|
||||
|
||||
CDBGroupIconListBag *pIcons = dynamic_cast<CDBGroupIconListBag*>(CWidgetManager::getInstance()->getElementFromId(invId + ":bag_icons"));
|
||||
if (pIcons != NULL) pIcons->setSearchFilter(eb->getInputString());
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER( CHandlerInvSetSearch, "inv_set_search" );
|
||||
|
||||
// ***************************************************************************
|
||||
// COMMON INVENTORIES Test if we can drop an item to a slot or a list
|
||||
class CHandlerInvCanDropTo : public IActionHandler
|
||||
|
|
|
@ -519,18 +519,26 @@ struct SBagOptions
|
|||
bool LastDbFilterMP;
|
||||
bool LastDbFilterMissMP;
|
||||
bool LastDbFilterTP;
|
||||
|
||||
bool SearchFilterChanged;
|
||||
std::vector<ucstring> SearchFilter;
|
||||
|
||||
// -----------------------
|
||||
SBagOptions()
|
||||
{
|
||||
InvType = CInventoryManager::InvUnknown;
|
||||
DbFilterArmor = DbFilterWeapon = DbFilterTool = DbFilterMP = DbFilterMissMP = DbFilterTP = NULL;
|
||||
LastDbFilterArmor = LastDbFilterWeapon = LastDbFilterTool = LastDbFilterMP = LastDbFilterMissMP = LastDbFilterTP = false;
|
||||
SearchFilterChanged = false;
|
||||
}
|
||||
|
||||
bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
bool isSomethingChanged(); // From last call ?
|
||||
|
||||
bool isSearchFilterChanged() const { return SearchFilterChanged; }
|
||||
void setSearchFilter(const ucstring &s);
|
||||
|
||||
bool getFilterArmor() const
|
||||
{
|
||||
if (DbFilterArmor == NULL) return true;
|
||||
|
@ -621,6 +629,8 @@ public:
|
|||
// Return true if the sheet can be displayed due to filters
|
||||
bool canDisplay(CDBCtrlSheet *pCS) { return _BO.canDisplay(pCS); }
|
||||
|
||||
void setSearchFilter(const ucstring &s) { _BO.setSearchFilter(s); }
|
||||
|
||||
private:
|
||||
|
||||
SBagOptions _BO;
|
||||
|
@ -652,6 +662,8 @@ public:
|
|||
// Return true if the sheet can be displayed due to filters
|
||||
bool canDisplay(CDBCtrlSheet *pCS) const { return _BO.canDisplay(pCS); }
|
||||
|
||||
void setSearchFilter(const ucstring &s) { _BO.setSearchFilter(s); }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// A child node
|
||||
|
|
Loading…
Reference in a new issue