Advertisement
Vudak

Untitled

Mar 5th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. local config = aura_env.config
  2.  
  3. local allTypes = {
  4. "INTERRUPT",
  5. "HARDCC", "STHARDCC",
  6. "SOFTCC", "STSOFTCC",
  7. "DISPEL", "DEFMDISPEL",
  8. "EXTERNAL", "HEALING",
  9. "UTILITY",
  10. "PERSONAL", "IMMUNITY",
  11. "DAMAGE",
  12. "TANK"
  13. }
  14.  
  15. aura_env.types = {}
  16. for _,type in ipairs(allTypes) do
  17. if config["enabled"..type] then
  18. aura_env.types[type] = true
  19. end
  20. end
  21.  
  22. local prioritizedSpellIDs = {
  23. [183752] = true, -- Disrupt
  24. }
  25.  
  26. local sortVars = {}
  27. local sortVarsIndex = {}
  28. for v = 1,5 do
  29. local var = config["sortVar"..v]
  30. if var and var ~= 1 then
  31. if not sortVarsIndex[var] then
  32. local index = #sortVars + 1
  33. sortVars[index] = var
  34. sortVarsIndex[var] = index
  35. end
  36. end
  37. end
  38.  
  39. local isAvail = (config["sortOrder"] == 1) and 0 or 1
  40. local isUnavail = (config["sortOrder"] == 1) and 1 or 0
  41.  
  42. aura_env.initSortIndex = function(state)
  43. state.sortValues = {}
  44.  
  45. for index,var in ipairs(sortVars) do
  46. if var == 2 then -- Type Priority
  47. local priority = config["priority"..state.type]
  48. if config["sortOrder"] == 2 then
  49. priority = 99 - priority
  50. end
  51. state.sortValues[index] = ("%02d"):format(priority)
  52. elseif var == 3 then -- Spell ID
  53. state.sortValues[index] = ("%06d"):format(state.spellId)
  54. elseif var == 4 then -- Member Class
  55. state.sortValues[index] = ("%02d"):format(state.member.classID)
  56. elseif var == 5 then -- Member Name
  57. state.sortValues[index] = ("%-12s"):format(state.member.name)
  58. elseif var == 6 then -- Availability
  59. local availValue = isAvail
  60. local isPrioritized = prioritizedSpellIDs[state.spellId]
  61. local timeValue = state.duration - (isPrioritized and 0.001 or 0)
  62. if config["sortOrder"] == 2 then
  63. timeValue = 9999999999.999 - timeValue
  64. end
  65.  
  66. state.sortValues[index] = ("%d%010.3f"):format(availValue, timeValue)
  67. end
  68. end
  69.  
  70. state.index = table.concat(state.sortValues)
  71. end
  72.  
  73. aura_env.updateSortIndex = function(state)
  74. local index = sortVarsIndex[6]
  75. if index then
  76. local prevSortValue = state.sortValues[index]
  77.  
  78. local isPrioritized = prioritizedSpellIDs[state.spellId]
  79. local availValue
  80. local timeValue
  81.  
  82. if state.stacks then
  83. if state.stacks > 0 then
  84. availValue = isAvail
  85. timeValue = state.duration - (isPrioritized and 0.001 or 0)
  86. else
  87. availValue = isUnavail
  88. timeValue = state.expirationTime
  89. end
  90. elseif state.expirationTime > GetTime() then
  91. availValue = isUnavail
  92. timeValue = state.expirationTime
  93. else
  94. availValue = isAvail
  95. timeValue = state.duration - (isPrioritized and 0.001 or 0)
  96. end
  97.  
  98. if config["sortOrder"] == 2 then
  99. timeValue = 9999999999.999 - timeValue
  100. end
  101. state.sortValues[index] = ("%d%010.3f"):format(availValue, timeValue)
  102.  
  103. if state.sortValues[index] ~= prevSortValue then
  104. state.index = table.concat(state.sortValues)
  105. return true
  106. end
  107. end
  108.  
  109. return false
  110.  
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement