/Tukui/modules/actionbars/Bar1.lua

http://github.com/Asphyxia/Tukui · Lua · 98 lines · 76 code · 7 blank · 15 comment · 8 complexity · 0a244aef01ac42d993718d9528900434 MD5 · raw file

  1. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2. if not C["actionbar"].enable == true then return end
  3. ---------------------------------------------------------------------------
  4. -- Setup Main Action Bar.
  5. -- Now used for stances, Bonus, Vehicle at the same time.
  6. -- Since t12, it's also working for druid cat stealth. (a lot requested)
  7. ---------------------------------------------------------------------------
  8. local bar = TukuiBar1
  9. --[[
  10. Bonus bar classes id
  11. DRUID: Caster: 0, Cat: 1, Tree of Life: 0, Bear: 3, Moonkin: 4
  12. WARRIOR: Battle Stance: 1, Defensive Stance: 2, Berserker Stance: 3
  13. ROGUE: Normal: 0, Stealthed: 1
  14. PRIEST: Normal: 0, Shadowform: 1
  15. When Possessing a Target: 5
  16. ]]--
  17. local Page = {
  18. ["DRUID"] = "[bonusbar:1,nostealth] 7; [bonusbar:1,stealth] 8; [bonusbar:2] 8; [bonusbar:3] 9; [bonusbar:4] 10;",
  19. ["WARRIOR"] = "[bonusbar:1] 7; [bonusbar:2] 8; [bonusbar:3] 9;",
  20. ["PRIEST"] = "[bonusbar:1] 7;",
  21. ["ROGUE"] = "[bonusbar:1] 7; [form:3] 7;",
  22. ["DEFAULT"] = "[bonusbar:5] 11; [bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6;",
  23. }
  24. local function GetBar()
  25. local condition = Page["DEFAULT"]
  26. local class = T.myclass
  27. local page = Page[class]
  28. if page then
  29. condition = condition.." "..page
  30. end
  31. condition = condition.." 1"
  32. return condition
  33. end
  34. bar:RegisterEvent("PLAYER_LOGIN")
  35. bar:RegisterEvent("PLAYER_ENTERING_WORLD")
  36. bar:RegisterEvent("KNOWN_CURRENCY_TYPES_UPDATE")
  37. bar:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
  38. bar:RegisterEvent("BAG_UPDATE")
  39. bar:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  40. bar:SetScript("OnEvent", function(self, event, ...)
  41. if event == "PLAYER_LOGIN" then
  42. local button
  43. for i = 1, NUM_ACTIONBAR_BUTTONS do
  44. button = _G["ActionButton"..i]
  45. self:SetFrameRef("ActionButton"..i, button)
  46. end
  47. self:Execute([[
  48. buttons = table.new()
  49. for i = 1, 12 do
  50. table.insert(buttons, self:GetFrameRef("ActionButton"..i))
  51. end
  52. ]])
  53. self:SetAttribute("_onstate-page", [[
  54. for i, button in ipairs(buttons) do
  55. button:SetAttribute("actionpage", tonumber(newstate))
  56. end
  57. ]])
  58. RegisterStateDriver(self, "page", GetBar())
  59. elseif event == "PLAYER_ENTERING_WORLD" then
  60. if T.toc < 40200 then MainMenuBar_UpdateKeyRing() end
  61. local button
  62. for i = 1, 12 do
  63. button = _G["ActionButton"..i]
  64. button:Size(T.buttonsize, T.buttonsize)
  65. button:ClearAllPoints()
  66. button:SetParent(bar)
  67. button:SetFrameStrata("BACKGROUND")
  68. button:SetFrameLevel(15)
  69. if i == 1 then
  70. if C["actionbar"].mainswap then
  71. button:Point("TOPLEFT", 5, -5)
  72. else
  73. button:Point("BOTTOMLEFT", 5, 5)
  74. end
  75. else
  76. local previous = _G["ActionButton"..i-1]
  77. button:Point("LEFT", previous, "RIGHT", T.buttonspacing, 0)
  78. end
  79. end
  80. elseif event == "ACTIVE_TALENT_GROUP_CHANGED" then
  81. -- attempt to fix blocked glyph change after switching spec.
  82. LoadAddOn("Blizzard_GlyphUI")
  83. else
  84. MainMenuBar_OnEvent(self, event, ...)
  85. end
  86. end)