mirror of
https://github.com/azerothcore/mod-transmog
synced 2025-11-29 22:48:30 +08:00
feat: add sorting feature and related conf (#174)
* feat: add sorting feature and related conf * fix: optimize sort feature * Update src/transmog_scripts.cpp
This commit is contained in:
@@ -72,6 +72,11 @@
|
||||
# Transmogrification.EnablePortable
|
||||
# Description: Enables / Disables the portable transmogrification NPC.
|
||||
# Default: 1
|
||||
#
|
||||
# Transmogrification.EnableSortByQualityAndName
|
||||
# Description: Enables / Disables the sorting of the items by quality and then by names
|
||||
# Default: 1
|
||||
#
|
||||
|
||||
Transmogrification.Enable = 1
|
||||
Transmogrification.UseCollectionSystem = 1
|
||||
@@ -90,6 +95,8 @@ Transmogrification.NotAllowed = ""
|
||||
|
||||
Transmogrification.EnablePortable = 1
|
||||
|
||||
Transmogrification.EnableSortByQualityAndName = 1
|
||||
|
||||
#
|
||||
# COPPER COST
|
||||
#
|
||||
@@ -220,6 +227,7 @@ Transmogrification.TokenAmount = 1
|
||||
# Description: Ignore stat count > 0 requirement for source items
|
||||
# Default: 0
|
||||
|
||||
|
||||
Transmogrification.AllowPoor = 0
|
||||
Transmogrification.AllowCommon = 0
|
||||
Transmogrification.AllowUncommon = 1
|
||||
|
||||
@@ -472,7 +472,11 @@ bool Transmogrification::AddCollectedAppearance(uint32 accountId, uint32 itemId)
|
||||
if (std::find(collectionCache[accountId].begin(), collectionCache[accountId].end(), itemId) == collectionCache[accountId].end())
|
||||
{
|
||||
collectionCache[accountId].push_back(itemId);
|
||||
|
||||
if (!sConfigMgr->GetOption<bool>("Transmogrification.EnableSortByQualityAndName", true)) {
|
||||
std::sort(collectionCache[accountId].begin(), collectionCache[accountId].end());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -374,6 +374,15 @@ bool ValidForTransmog (Player* player, Item* target, Item* source, bool hasSearc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CmpTmog (Item* i1, Item* i2)
|
||||
{
|
||||
const ItemTemplate* i1t = i1->GetTemplate();
|
||||
const ItemTemplate* i2t = i2->GetTemplate();
|
||||
const int q1 = 7-i1t->Quality;
|
||||
const int q2 = 7-i2t->Quality;
|
||||
return std::tie(q1, i1t->Name1) < std::tie(q2, i2t->Name1);
|
||||
}
|
||||
|
||||
std::vector<Item*> GetValidTransmogs (Player* player, Item* target, bool hasSearch, std::string searchTerm)
|
||||
{
|
||||
std::vector<Item*> allowedItems;
|
||||
@@ -415,6 +424,11 @@ std::vector<Item*> GetValidTransmogs (Player* player, Item* target, bool hasSear
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sConfigMgr->GetOption<bool>("Transmogrification.EnableSortByQualityAndName", true)) {
|
||||
sort(allowedItems.begin(), allowedItems.end(), CmpTmog);
|
||||
}
|
||||
|
||||
return allowedItems;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user