test sort

This commit is contained in:
Bunny67
2018-07-10 21:09:05 +03:00
parent 7c6d7727b3
commit 7b1074d427
5 changed files with 238 additions and 60 deletions
+209 -7
View File
@@ -266,16 +266,207 @@ function GetMapNameByID(id)
return mapByID[tonumber(id)]
end
local t = {
[6218] = 16,
[6339] = 16,
[6342] = 16,
[6344] = 16,
[6346] = 16,
[6347] = 16,
[6348] = 16,
[6349] = 16,
[6375] = 16,
[6377] = 16,
[10938] = 16,
[10939] = 16,
[10940] = 16,
[10978] = 16,
[10998] = 16,
[11038] = 16,
[11039] = 16,
[11081] = 16,
[11082] = 16,
[11083] = 16,
[11084] = 16,
[11098] = 16,
[11101] = 16,
[11130] = 16,
[11134] = 16,
[11135] = 16,
[11137] = 16,
[11138] = 16,
[11139] = 16,
[11145] = 16,
[11150] = 16,
[11151] = 16,
[11152] = 16,
[11163] = 16,
[11164] = 16,
[11165] = 16,
[11166] = 16,
[11167] = 16,
[11168] = 16,
[11174] = 16,
[11175] = 16,
[11176] = 16,
[11177] = 16,
[11178] = 16,
[11202] = 16,
[11203] = 16,
[11204] = 16,
[11205] = 16,
[11206] = 16,
[11207] = 16,
[11208] = 16,
[11224] = 16,
[11225] = 16,
[11226] = 16,
[11813] = 16,
[14343] = 16,
[14344] = 16,
[16202] = 16,
[16203] = 16,
[16204] = 16,
[16207] = 16,
[16214] = 16,
[16215] = 16,
[16216] = 16,
[16217] = 16,
[16218] = 16,
[16219] = 16,
[16220] = 16,
[16221] = 16,
[16222] = 16,
[16223] = 16,
[16224] = 16,
[16242] = 16,
[16243] = 16,
[16244] = 16,
[16245] = 16,
[16246] = 16,
[16247] = 16,
[16248] = 16,
[16249] = 16,
[16250] = 16,
[16251] = 16,
[16252] = 16,
[16253] = 16,
[16254] = 16,
[16255] = 16,
[17725] = 16,
[18259] = 16,
[18260] = 16,
[19444] = 16,
[19445] = 16,
[19446] = 16,
[19447] = 16,
[19448] = 16,
[19449] = 16,
[20634] = 16,
[20725] = 16,
[20726] = 16,
[20727] = 16,
[20728] = 16,
[20729] = 16,
[20730] = 16,
[20731] = 16,
[20732] = 16,
[20733] = 16,
[20735] = 16,
[20736] = 16,
[20752] = 16,
[20753] = 16,
[20754] = 16,
[20755] = 16,
[20756] = 16,
[20757] = 16,
[20758] = 16,
[22392] = 16,
[765] = 8,
[785] = 8,
[1401] = 8,
[2447] = 8,
[2449] = 8,
[2450] = 8,
[2452] = 8,
[2453] = 8,
[3355] = 8,
[3356] = 8,
[3357] = 8,
[3358] = 8,
[3369] = 8,
[3818] = 8,
[3819] = 8,
[3820] = 8,
[3821] = 8,
[4625] = 8,
[5056] = 8,
[5168] = 8,
[8153] = 8,
[8831] = 8,
[8836] = 8,
[8838] = 8,
[8839] = 8,
[8845] = 8,
[8846] = 8,
[11022] = 8,
[11040] = 8,
[11514] = 8,
[11951] = 8,
[11952] = 8,
[13463] = 8,
[13464] = 8,
[13465] = 8,
[13466] = 8,
[13467] = 8,
[13468] = 8,
[16205] = 8,
[16208] = 8,
[17034] = 8,
[17035] = 8,
[17036] = 8,
[17037] = 8,
[17038] = 8,
[17760] = 8,
[18297] = 8,
[19726] = 8,
[19727] = 8,
[22094] = 8,
[6265] = 4,
[2516] = 2,
[2519] = 2,
[3033] = 2,
[3465] = 2,
[4960] = 2,
[5568] = 2,
[8067] = 2,
[8068] = 2,
[8069] = 2,
[10512] = 2,
[10513] = 2,
[11284] = 2,
[11363] = 2,
[11630] = 2,
[13377] = 2,
[15997] = 2,
[19317] = 2,
[2512] = 1,
[2515] = 1,
[3030] = 1,
[3464] = 1,
[9399] = 1,
[11285] = 1,
[12654] = 1,
[18042] = 1,
[19316] = 1,
}
local bagTypes = {
[LBIF["Bag"]] = 0,
[LBIF["Quiver"]] = 1,
[LBIF["Ammo Pouch"]] = 2,
[LBIF["Soul Bag"]] = 4,
[LBIF["Leatherworking Bag"]] = 8,
[LBIF["Herb Bag"]] = 16,
[LBIF["Enchanting Bag"]] = 32,
[LBIF["Engineering Bag"]] = 64,
[LBIF["Mining Bag"]] = 128
[LBIF["Herb Bag"]] = 8,
[LBIF["Enchanting Bag"]] = 16,
}
function GetItemFamily(id)
@@ -286,8 +477,19 @@ function GetItemFamily(id)
id = match(id, "item:(%d+)")
end
return t[id] or 0
end
function GetBagFamily(id)
if not id then return end
if type(id) == "table" or type(id) == "function" then return end
if type(id) == "string" then
id = match(id, "item:(%d+)")
end
local _, _, _, _, _, itemType = GetItemInfo(id)
return bagTypes[itemType]
return bagTypes[itemType] or 0
end
local arrow
@@ -8,114 +8,78 @@ if not lib then return end
local GAME_LOCALE = GetLocale()
lib:SetBaseTranslations {
["Bag"] = true,
["Quiver"] = true,
["Ammo Pouch"] = true,
["Soul Bag"] = true,
["Leatherworking Bag"] = true,
["Herb Bag"] = true,
["Enchanting Bag"] = true,
["Engineering Bag"] = true,
["Mining Bag"] = true,
}
if GAME_LOCALE == "enUS" then
lib:SetCurrentTranslations(true)
elseif GAME_LOCALE == "deDE" then
lib:SetCurrentTranslations {
["Bag"] = "Bag",
["Quiver"] = "Quiver",
["Ammo Pouch"] = "Ammo Pouch",
["Soul Bag"] = "Soul Bag",
["Leatherworking Bag"] = "Leatherworking Bag",
["Herb Bag"] = "Herb Bag",
["Enchanting Bag"] = "Enchanting Bag",
["Engineering Bag"] = "Engineering Bag",
["Mining Bag"] = "Mining Bag",
}
elseif GAME_LOCALE == "frFR" then
lib:SetCurrentTranslations {
["Bag"] = "Bag",
["Quiver"] = "Quiver",
["Ammo Pouch"] = "Ammo Pouch",
["Soul Bag"] = "Soul Bag",
["Leatherworking Bag"] = "Leatherworking Bag",
["Herb Bag"] = "Herb Bag",
["Enchanting Bag"] = "Enchanting Bag",
["Engineering Bag"] = "Engineering Bag",
["Mining Bag"] = "Mining Bag",
}
elseif GAME_LOCALE == "zhCN" then
lib:SetCurrentTranslations {
["Bag"] = "Bag",
["Quiver"] = "Quiver",
["Ammo Pouch"] = "Ammo Pouch",
["Soul Bag"] = "Soul Bag",
["Leatherworking Bag"] = "Leatherworking Bag",
["Herb Bag"] = "Herb Bag",
["Enchanting Bag"] = "Enchanting Bag",
["Engineering Bag"] = "Engineering Bag",
["Mining Bag"] = "Mining Bag",
}
elseif GAME_LOCALE == "zhTW" then
lib:SetCurrentTranslations {
["Bag"] = "Bag",
["Quiver"] = "Quiver",
["Ammo Pouch"] = "Ammo Pouch",
["Soul Bag"] = "Soul Bag",
["Leatherworking Bag"] = "Leatherworking Bag",
["Herb Bag"] = "Herb Bag",
["Enchanting Bag"] = "Enchanting Bag",
["Engineering Bag"] = "Engineering Bag",
["Mining Bag"] = "Mining Bag",
}
elseif GAME_LOCALE == "koKR" then
lib:SetCurrentTranslations {
["Bag"] = "Bag",
["Quiver"] = "Quiver",
["Ammo Pouch"] = "Ammo Pouch",
["Soul Bag"] = "Soul Bag",
["Leatherworking Bag"] = "Leatherworking Bag",
["Herb Bag"] = "Herb Bag",
["Enchanting Bag"] = "Enchanting Bag",
["Engineering Bag"] = "Engineering Bag",
["Mining Bag"] = "Mining Bag",
}
elseif GAME_LOCALE == "esES" then
lib:SetCurrentTranslations {
["Bag"] = "Bag",
["Quiver"] = "Quiver",
["Ammo Pouch"] = "Ammo Pouch",
["Soul Bag"] = "Soul Bag",
["Leatherworking Bag"] = "Leatherworking Bag",
["Herb Bag"] = "Herb Bag",
["Enchanting Bag"] = "Enchanting Bag",
["Engineering Bag"] = "Engineering Bag",
["Mining Bag"] = "Mining Bag",
}
elseif GAME_LOCALE == "esMX" then
lib:SetCurrentTranslations {
["Bag"] = "Bag",
["Quiver"] = "Quiver",
["Ammo Pouch"] = "Ammo Pouch",
["Soul Bag"] = "Soul Bag",
["Leatherworking Bag"] = "Leatherworking Bag",
["Herb Bag"] = "Herb Bag",
["Enchanting Bag"] = "Enchanting Bag",
["Engineering Bag"] = "Engineering Bag",
["Mining Bag"] = "Mining Bag",
}
elseif GAME_LOCALE == "ruRU" then
lib:SetCurrentTranslations {
["Bag"] = "Bag",
["Quiver"] = "Quiver",
["Ammo Pouch"] = "Ammo Pouch",
["Soul Bag"] = "Soul Bag",
["Leatherworking Bag"] = "Leatherworking Bag",
["Herb Bag"] = "Herb Bag",
["Enchanting Bag"] = "Enchanting Bag",
["Engineering Bag"] = "Engineering Bag",
["Mining Bag"] = "Mining Bag",
["Quiver"] = "Колчан",
["Ammo Pouch"] = "Подсумок",
["Soul Bag"] = "Сумка душ",
["Herb Bag"] = "Сумка травника",
["Enchanting Bag"] = "Сумка зачаровывателя",
}
else
error(string.format("%s: Locale %q not supported", MAJOR_VERSION, GAME_LOCALE))
+1 -1
View File
@@ -3,5 +3,5 @@
<Script file="LibBabble-3.0.lua"/>
<Script file="LibBabble-Class-3.0.lua"/>
<Script file="LibBabble-Zone-3.0.lua"/>
<Script file="LibBabble-ItemFamily-3.0.lua"/>
<Script file="LibBabble-ItemBagFamily-3.0.lua"/>
</Ui>
+3 -6
View File
@@ -48,11 +48,8 @@ local SEARCH = SEARCH
local SEARCH_STRING = ""
B.ProfessionColors = {
["8"] = {224/255, 187/255, 74/255}, -- Leatherworking
["16"] = {18/255, 181/255, 32/255}, -- Herbs
["32"] = {160/255, 3/255, 168/255}, -- Enchanting
["64"] = {232/255, 118/255, 46/255}, -- Engineering
["128"] = {105/255, 79/255, 7/255}, -- Mining
["8"] = {18/255, 181/255, 32/255}, -- Herbs
["16"] = {160/255, 3/255, 168/255}, -- Enchanting
}
function B:GetContainerFrame(arg)
@@ -449,7 +446,7 @@ function B:Layout(isBank)
end
f.Bags[bagID].numSlots = numSlots
f.Bags[bagID].type = GetItemFamily(GetInventoryItemLink("player", ContainerIDToInventoryID(bagID)))
f.Bags[bagID].type = GetBagFamily(GetInventoryItemLink("player", ContainerIDToInventoryID(bagID)))
--Hide unused slots
for i = 1, MAX_CONTAINER_ITEMS do
+20 -5
View File
@@ -258,7 +258,7 @@ local function IterateForwards(bagList, i)
end
local function IterateBackwards(bagList, i)
i = i + 1
--[[i = i + 1
local step = 1
for ii = getn(bagList), 1, -1 do
local bag = bagList[ii]
@@ -273,6 +273,21 @@ local function IterateBackwards(bagList, i)
step = step + 1
end
end
end]]
i = i + 1
local step = 1
for _, bag in bagList do
local slots = B:GetNumSlots(bag)
if i > slots + step then
step = step + slots
else
for slot = 1, slots do
if step == i then
return i, bag, slot
end
step = step + 1
end
end
end
bagRole = nil
end
@@ -376,7 +391,7 @@ function B:IsSpecialtyBag(bagID)
local bag = GetInventoryItemLink("player", inventorySlot)
if not bag then return false end
local family = GetItemFamily(bag)
local family = GetBagFamily(bag)
if family == 0 or family == nil then return false end
return family
@@ -385,13 +400,13 @@ end
function B:CanItemGoInBag(bag, slot, targetBag)
local item = bagIDs[B:Encode_BagSlot(bag, slot)]
local itemFamily = GetItemFamily(item)
if itemFamily and itemFamily > 0 then
if itemFamily then
local equipSlot = select(8, GetItemInfo(item))
if equipSlot == "INVTYPE_BAG" then
itemFamily = 1
end
end
local bagFamily = GetItemFamily(targetBag)
local bagFamily = GetBagFamily(GetInventoryItemLink("player", ContainerIDToInventoryID(targetBag)))
if itemFamily then
return (bagFamily == 0) or band(itemFamily, bagFamily) > 0
else
@@ -482,7 +497,7 @@ function B.Sort(bags, sorter, invertDirection)
local link = B:GetItemLink(bag, slot)
local id = B:GetItemID(bag, slot)
if id then
if link then
if blackList[GetItemInfo(id)] then
blackListedSlots[bagSlot] = true
end