/Tukui/modules/addonskins/bigwigs.lua

http://github.com/Asphyxia/Tukui · Lua · 204 lines · 161 code · 27 blank · 16 comment · 41 complexity · 02b453d5f5b145003eecab0dfe779f56 MD5 · raw file

  1. --[[
  2. Author: Affli@RU-Howling Fjord,
  3. Modified: Elv
  4. All rights reserved.
  5. ]]--
  6. local T, C, L = unpack(select(2, ...))
  7. if not IsAddOnLoaded("BigWigs") or not C.Addon_Skins.bigwigs then return end
  8. local buttonsize = 19
  9. -- init some tables to store backgrounds
  10. local freebg = {}
  11. -- styling functions
  12. local createbg = function()
  13. local bg = CreateFrame("Frame")
  14. bg:SetTemplate("Transparent")
  15. return bg
  16. end
  17. local function freestyle(bar)
  18. -- reparent and hide bar background
  19. local bg = bar:Get("bigwigs:Tukui:bg")
  20. if bg then
  21. bg:ClearAllPoints()
  22. bg:SetParent(UIParent)
  23. bg:Hide()
  24. freebg[#freebg + 1] = bg
  25. end
  26. -- reparent and hide icon background
  27. local ibg = bar:Get("bigwigs:Tukui:bg")
  28. if ibg then
  29. ibg:ClearAllPoints()
  30. ibg:SetParent(UIParent)
  31. ibg:Hide()
  32. freebg[#freebg + 1] = ibg
  33. end
  34. -- replace dummies with original method functions
  35. bar.candyBarBar.SetPoint=bar.candyBarBar.OldSetPoint
  36. bar.candyBarIconFrame.SetWidth=bar.candyBarIconFrame.OldSetWidth
  37. bar.SetScale=bar.OldSetScale
  38. end
  39. local applystyle = function(bar)
  40. -- general bar settings
  41. bar:SetHeight(buttonsize)
  42. bar:SetScale(1)
  43. bar.OldSetScale=bar.SetScale
  44. bar.SetScale=T.dummy
  45. -- create or reparent and use bar background
  46. local bg = nil
  47. if #freebg > 0 then
  48. bg = table.remove(freebg)
  49. else
  50. bg = createbg()
  51. end
  52. bg:SetParent(bar)
  53. bg:ClearAllPoints()
  54. bg:Point("TOPLEFT", bar, "TOPLEFT", -2, 2)
  55. bg:Point("BOTTOMRIGHT", bar, "BOTTOMRIGHT", 2, -2)
  56. bg:SetFrameStrata("BACKGROUND")
  57. bg:Show()
  58. bar:Set("bigwigs:Tukui:bg", bg)
  59. -- create or reparent and use icon background
  60. local ibg = nil
  61. if bar.candyBarIconFrame:GetTexture() then
  62. if #freebg > 0 then
  63. ibg = table.remove(freebg)
  64. else
  65. ibg = createbg()
  66. end
  67. ibg:SetParent(bar)
  68. ibg:ClearAllPoints()
  69. ibg:Point("TOPLEFT", bar.candyBarIconFrame, "TOPLEFT", -2, 2)
  70. ibg:Point("BOTTOMRIGHT", bar.candyBarIconFrame, "BOTTOMRIGHT", 2, -2)
  71. ibg:SetFrameStrata("BACKGROUND")
  72. ibg:Show()
  73. bar:Set("bigwigs:Tukui:bg", ibg)
  74. end
  75. -- setup timer and bar name fonts and positions
  76. bar.candyBarLabel:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  77. bar.candyBarLabel:SetShadowColor(0, 0, 0, 0)
  78. bar.candyBarLabel:SetJustifyH("LEFT")
  79. bar.candyBarLabel:ClearAllPoints()
  80. bar.candyBarLabel:Point("LEFT", bar, "LEFT", 4, 0)
  81. bar.candyBarDuration:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  82. bar.candyBarDuration:SetShadowColor(0, 0, 0, 0)
  83. bar.candyBarDuration:SetJustifyH("RIGHT")
  84. bar.candyBarDuration:ClearAllPoints()
  85. bar.candyBarDuration:Point("RIGHT", bar, "RIGHT", -4, 0)
  86. -- setup bar positions and look
  87. bar.candyBarBar:ClearAllPoints()
  88. bar.candyBarBar:SetAllPoints(bar)
  89. bar.candyBarBar.OldSetPoint = bar.candyBarBar.SetPoint
  90. bar.candyBarBar.SetPoint=T.dummy
  91. bar.candyBarBar:SetStatusBarTexture(C["media"].normTex)
  92. bar.candyBarBackground:SetTexture(unpack(C.media.backdropcolor))
  93. -- setup icon positions and other things
  94. bar.candyBarIconFrame:ClearAllPoints()
  95. bar.candyBarIconFrame:Point("BOTTOMRIGHT", bar, "BOTTOMLEFT", -7, 0)
  96. bar.candyBarIconFrame:SetSize(buttonsize, buttonsize)
  97. bar.candyBarIconFrame.OldSetWidth = bar.candyBarIconFrame.SetWidth
  98. bar.candyBarIconFrame.SetWidth=T.dummy
  99. bar.candyBarIconFrame:SetTexCoord(0.08, 0.92, 0.08, 0.92)
  100. end
  101. local f = CreateFrame("Frame")
  102. local function RegisterStyle()
  103. if not BigWigs then return end
  104. local bars = BigWigs:GetPlugin("Bars", true)
  105. local prox = BigWigs:GetPlugin("Proximity", true)
  106. if bars then
  107. bars:RegisterBarStyle("Tukui", {
  108. apiVersion = 1,
  109. version = 1,
  110. GetSpacing = function(bar) return 7 end,
  111. ApplyStyle = applystyle,
  112. BarStopped = freestyle,
  113. GetStyleName = function() return "Tukui" end,
  114. })
  115. end
  116. if prox and BigWigs.pluginCore.modules.Bars.db.profile.barStyle == "Tukui" then
  117. hooksecurefunc(BigWigs.pluginCore.modules.Proximity, "RestyleWindow", function()
  118. BigWigsProximityAnchor:SetTemplate("Transparent")
  119. end)
  120. end
  121. end
  122. local function PositionBWAnchor()
  123. if not BigWigsAnchor then return end
  124. BigWigsAnchor:ClearAllPoints()
  125. if E.CheckAddOnShown() == true then
  126. if C["chat"].background == true and T.ChatRightShown == true then
  127. BigWigsAnchor:Point("TOP", ChatRBGDummy, "TOP", 12, 0)
  128. else
  129. BigWigsAnchor:Point("TOP", ChatRBGDummy, "TOP", 12, -32)
  130. end
  131. else
  132. BigWigsAnchor:Point("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -5, 8)
  133. end
  134. end
  135. local function PositionBWAnchor()
  136. if not BigWigsAnchor then return end
  137. BigWigsAnchor:ClearAllPoints()
  138. BigWigsAnchor:Point("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -5, 3)
  139. end
  140. f:RegisterEvent("ADDON_LOADED")
  141. f:SetScript("OnEvent", function(self, event, addon)
  142. if event == "ADDON_LOADED" and addon == "BigWigs_Plugins" then
  143. RegisterStyle()
  144. local profile = BigWigs3DB["profileKeys"][T.myname.." - "..T.myrealm]
  145. local path = BigWigs3DB["namespaces"]["BigWigs_Plugins_Bars"]["profiles"][profile]
  146. path.texture = "Tukui Norm"
  147. path.barStyle = "Tukui"
  148. path.font = "Tukui Font"
  149. local path = BigWigs3DB["namespaces"]["BigWigs_Plugins_Messages"]["profiles"][profile]
  150. path.font = "Tukui Font"
  151. local path = BigWigs3DB["namespaces"]["BigWigs_Plugins_Proximity"]["profiles"][profile]
  152. path.font = "Tukui Font"
  153. f:UnregisterEvent("ADDON_LOADED")
  154. elseif event == "PLAYER_ENTERING_WORLD" then
  155. LoadAddOn("BigWigs_Core")
  156. LoadAddOn("BigWigs_Plugins")
  157. LoadAddOn("BigWigs_Options")
  158. BigWigs:Enable()
  159. BigWigsOptions:SendMessage("BigWigs_StartConfigureMode", true)
  160. BigWigsOptions:SendMessage("BigWigs_StopConfigureMode")
  161. PositionBWAnchor()
  162. if Skada and Skada:GetWindows() and Skada:GetWindows()[1] and C["skin"].embed == "Skada" then
  163. Skada:GetWindows()[1].bargroup:HookScript("OnShow", function() PositionBWAnchor() end)
  164. Skada:GetWindows()[1].bargroup:HookScript("OnHide", function() PositionBWAnchor() end)
  165. elseif Recount_MainWindow and C["skin"].embed == "Recount" then
  166. Recount_MainWindow:HookScript("OnShow", function() PositionBWAnchor() end)
  167. Recount_MainWindow:HookScript("OnHide", function() PositionBWAnchor() end)
  168. elseif OmenAnchor and C["skin"].embed == "Omen" then
  169. OmenAnchor:HookScript("OnShow", function() PositionBWAnchor() end)
  170. OmenAnchor:HookScript("OnHide", function() PositionBWAnchor() end)
  171. end
  172. elseif event == "PLAYER_REGEN_DISABLED" then
  173. PositionBWAnchor()
  174. elseif event == "PLAYER_REGEN_ENABLED" then
  175. PositionBWAnchor()
  176. end
  177. end)