Advertisement
ScratchMonkey

AceConfigDialog sort error when used with Adibags Config

Jun 25th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. -- Demonstrates sorting issue in AdiBags config dialog using AceConfigDialog-3.0
  2.  
  3. local keySort = {}
  4.  
  5. keySort[1] = "Ancient Mana"
  6. keySort[2] = "description"
  7. keySort[4] = "Trade Goods"
  8. keySort[8] = "Quest"
  9. keySort[16] = "Key"
  10. keySort[17] = "Relic"
  11. keySort[9] = "New"
  12. keySort[18] = "Junk"
  13. keySort[19] = "Item Enhancement!"
  14. keySort[10] = "Tradeskill"
  15. keySort[11] = "Power"
  16. keySort[3] = "Champion Equipment"
  17. keySort[6] = "BoA"
  18. keySort[12] = "Miscellaneous"
  19. keySort[5] = "Recipe"
  20. keySort[15] = "Item Enhancement"
  21. keySort[13] = "Equipment"
  22. keySort[7] = "newAssoc"
  23. keySort[14] = "Consumable"
  24.  
  25. local tempOrders = {}
  26.  
  27. tempOrders["Ancient Mana"] = 0
  28. tempOrders["description"] = 1
  29. tempOrders["Champion Equipment"] = 0
  30. tempOrders["Trade Goods"] = 0
  31. tempOrders["Recipe"] = 0
  32. tempOrders["BoA"] = 0
  33. tempOrders["newAssoc"] = 10
  34. tempOrders["Quest"] = 30
  35. tempOrders["New"] = 100
  36. tempOrders["Tradeskill"] = 20
  37. tempOrders["Power"] = 0
  38. tempOrders["Miscellaneous"] = -20
  39. tempOrders["Equipment"] = 10
  40. tempOrders["Consumable"] = -10
  41. tempOrders["Item Enhancement"] = 0
  42. tempOrders["Item Enhancement!"] = 0
  43. tempOrders["Relic"] = 0
  44. tempOrders["Junk"] = -40
  45. tempOrders["Key"] = 0
  46.  
  47. local tempNames = {}
  48.  
  49. tempNames["Ancient Mana"] = "Ancient Mana"
  50. tempNames["description"] = "Allow you manually redefine the section in which an item should be put. Simply drag an item on the section title."
  51. tempNames["Champion Equipment"] = "Champion Equipment"
  52. tempNames["Trade Goods"] = "Trade Goods"
  53. tempNames["Recipe"] = "Recipe"
  54. tempNames["BoA"] = "BoA"
  55. tempNames["newAssoc"] = "New Override"
  56. tempNames["Quest"] = "Quest"
  57. tempNames["New"] = "New"
  58. tempNames["Tradeskill"] = "Tradeskill"
  59. tempNames["Power"] = "Power"
  60. tempNames["Miscellaneous"] = "Miscellaneous"
  61. tempNames["Equipment"] = "Equipment"
  62. tempNames["Consumable"] = "Consumable"
  63. tempNames["Item Enhancement"] = "Item Enhancement"
  64. tempNames["Item Enhancement!"] = "Item Enhancement!"
  65. tempNames["Relic"] = "Relic"
  66. tempNames["Junk"] = "Junk"
  67. tempNames["Key"] = "Key"
  68.  
  69. local function compareOptions(a,b)
  70.     if not a then
  71.         return true
  72.     end
  73.     if not b then
  74.         return false
  75.     end
  76.     local OrderA, OrderB = tempOrders[a] or 100, tempOrders[b] or 100
  77.     if OrderA == OrderB then
  78.         local NameA = (type(tempNames[a]) == "string") and tempNames[a] or ""
  79.         local NameB = (type(tempNames[b]) == "string") and tempNames[b] or ""
  80.         return NameA:upper() < NameB:upper()
  81.     end
  82.     if OrderA < 0 then
  83.         if OrderB > 0 then
  84.             return false
  85.         end
  86.     else
  87.         if OrderB < 0 then
  88.             return true
  89.         end
  90.     end
  91.     return OrderA < OrderB
  92. end
  93.  
  94. table.sort(keySort, compareOptions)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement