Added: Quality range filter to inventory

--HG--
branch : develop
This commit is contained in:
Nimetu 2017-07-12 23:45:56 +03:00
parent 7350291a56
commit c435f77201
2 changed files with 35 additions and 1 deletions

View file

@ -2014,12 +2014,38 @@ bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */)
// *************************************************************************** // ***************************************************************************
void SBagOptions::setSearchFilter(const ucstring &s) void SBagOptions::setSearchFilter(const ucstring &s)
{ {
SearchQualityMin = 0;
SearchQualityMax = 999;
SearchFilter.clear(); SearchFilter.clear();
SearchFilterChanged = true; SearchFilterChanged = true;
if (!s.empty()) if (!s.empty())
{ {
splitUCString(toLower(s), ucstring(" "), SearchFilter); std::vector<ucstring> words;
splitUCString(toLower(s), ucstring(" "), words);
size_t pos;
for(int i = 0; i<words.size(); ++i)
{
std::string kw = words[i].toUtf8();
pos = kw.find("-");
if (pos != std::string::npos)
{
uint16 first;
uint16 last;
if (fromString(kw.substr(0, pos), first))
SearchQualityMin = first;
if (fromString(kw.substr(pos+1), last))
SearchQualityMax = last;
if (first == 0 && last == 0)
SearchFilter.push_back(words[i]);
}
else
SearchFilter.push_back(words[i]);
}
} }
} }
@ -2114,6 +2140,10 @@ bool SBagOptions::canDisplay(CDBCtrlSheet *pCS) const
} }
} }
// Quality range
if (SearchQualityMin > pCS->getQuality() || SearchQualityMax < pCS->getQuality())
return false;
// Armor // Armor
if ((pIS->Family == ITEMFAMILY::ARMOR) || if ((pIS->Family == ITEMFAMILY::ARMOR) ||
(pIS->Family == ITEMFAMILY::JEWELRY)) (pIS->Family == ITEMFAMILY::JEWELRY))

View file

@ -521,6 +521,8 @@ struct SBagOptions
bool LastDbFilterTP; bool LastDbFilterTP;
bool SearchFilterChanged; bool SearchFilterChanged;
uint16 SearchQualityMin;
uint16 SearchQualityMax;
std::vector<ucstring> SearchFilter; std::vector<ucstring> SearchFilter;
// ----------------------- // -----------------------
@ -530,6 +532,8 @@ struct SBagOptions
DbFilterArmor = DbFilterWeapon = DbFilterTool = DbFilterMP = DbFilterMissMP = DbFilterTP = NULL; DbFilterArmor = DbFilterWeapon = DbFilterTool = DbFilterMP = DbFilterMissMP = DbFilterTP = NULL;
LastDbFilterArmor = LastDbFilterWeapon = LastDbFilterTool = LastDbFilterMP = LastDbFilterMissMP = LastDbFilterTP = false; LastDbFilterArmor = LastDbFilterWeapon = LastDbFilterTool = LastDbFilterMP = LastDbFilterMissMP = LastDbFilterTP = false;
SearchFilterChanged = false; SearchFilterChanged = false;
SearchQualityMin = 0;
SearchQualityMax = 999;
} }
bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);