/Tukui/modules/addonskins/Recount.lua

http://github.com/Asphyxia/Tukui · Lua · 184 lines · 157 code · 19 blank · 8 comment · 9 complexity · 6543d5f54648fa627d0477e3a458563d MD5 · raw file

  1. --[[ Credit Tukz ]]--
  2. local T, C, L = unpack(Tukui)
  3. if not IsAddOnLoaded("Recount") or not C.Addon_Skins.Recount then return end
  4. local Recount = _G.Recount
  5. local function SkinFrame(frame)
  6. frame.bgMain = CreateFrame("Frame", nil, frame)
  7. frame.bgMain:SetTemplate("Transparent")
  8. frame.bgMain:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT")
  9. frame.bgMain:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT")
  10. frame.bgMain:SetPoint("TOP", frame, "TOP", 0, -7)
  11. frame.bgMain:SetFrameLevel(frame:GetFrameLevel())
  12. frame.CloseButton:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -1, -9)
  13. frame.TitleBackground = CreateFrame("Frame", nil, frame.bgMain)
  14. frame.TitleBackground:SetPoint("TOP", 0)
  15. frame.TitleBackground:SetPoint("LEFT", 0)
  16. frame.TitleBackground:SetPoint("RIGHT", 0)
  17. frame.TitleBackground:SetHeight(24)
  18. frame.TitleBackground:SetTemplate("Transparent")
  19. frame.Title:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  20. frame.Title:SetParent(frame.TitleBackground)
  21. frame.Title:ClearAllPoints()
  22. frame.Title:SetPoint("LEFT", 4, 0)
  23. frame.CloseButton:SetNormalTexture("")
  24. frame.CloseButton:SetPushedTexture("")
  25. frame.CloseButton:SetHighlightTexture("")
  26. frame.CloseButton.t = frame.CloseButton:CreateFontString(nil, "OVERLAY")
  27. frame.CloseButton.t:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  28. frame.CloseButton.t:SetPoint("CENTER", 0, 1)
  29. frame.CloseButton.t:SetText(T.datacolor.."X")
  30. end
  31. Recount.UpdateBarTextures = function(self)
  32. for k, v in pairs(Recount.MainWindow.Rows) do
  33. v.StatusBar:SetStatusBarTexture(C["media"].normTex)
  34. v.StatusBar:GetStatusBarTexture():SetHorizTile(false)
  35. v.StatusBar:GetStatusBarTexture():SetVertTile(false)
  36. v.LeftText:SetPoint("LEFT", 4, 1)
  37. v.LeftText:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  38. v.RightText:SetPoint("RIGHT", -4, 1)
  39. v.RightText:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  40. end
  41. end
  42. Recount.SetBarTextures = Recount.UpdateBarTextures
  43. -- Fix bar textures as they're created
  44. Recount.SetupBar_ = Recount.SetupBar
  45. Recount.SetupBar = function(self, bar)
  46. self:SetupBar_(bar)
  47. bar.StatusBar:SetStatusBarTexture(C["media"].normTex)
  48. end
  49. -- Skin frames when they're created
  50. Recount.CreateFrame_ = Recount.CreateFrame
  51. Recount.CreateFrame = function(self, Name, Title, Height, Width, ShowFunc, HideFunc)
  52. local frame = self:CreateFrame_(Name, Title, Height, Width, ShowFunc, HideFunc)
  53. SkinFrame(frame)
  54. return frame
  55. end
  56. -- frame we want to skins
  57. local elements = {
  58. Recount.MainWindow,
  59. Recount.ConfigWindow,
  60. Recount.GraphWindow,
  61. Recount.DetailWindow,
  62. Recount.ResetFrame,
  63. }
  64. -- skin them
  65. for i = 1, getn(elements) do
  66. local frame = elements[i]
  67. if frame then
  68. SkinFrame(frame)
  69. end
  70. end
  71. --Update Textures
  72. Recount:UpdateBarTextures()
  73. -- skin dropdown
  74. Recount.MainWindow.FileButton:HookScript("OnClick", function(self) if LibDropdownFrame0 then LibDropdownFrame0:SetTemplate() end end)
  75. -- reskin button
  76. Recount.MainWindow.RightButton:SetTemplate("Transparent")
  77. Recount.MainWindow.RightButton:SetNormalTexture("")
  78. Recount.MainWindow.RightButton:SetPushedTexture("")
  79. Recount.MainWindow.RightButton:SetHighlightTexture("")
  80. Recount.MainWindow.RightButton:SetSize(16, 16)
  81. Recount.MainWindow.RightButton:FontString("text", C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  82. Recount.MainWindow.RightButton.text:SetText(T.datacolor..">")
  83. Recount.MainWindow.RightButton.text:SetPoint("CENTER", 1, 1)
  84. Recount.MainWindow.RightButton:ClearAllPoints()
  85. Recount.MainWindow.RightButton:SetPoint("RIGHT", Recount.MainWindow.CloseButton, "LEFT", -2, 0)
  86. Recount.MainWindow.LeftButton:SetTemplate("Transparent")
  87. Recount.MainWindow.LeftButton:SetNormalTexture("")
  88. Recount.MainWindow.LeftButton:SetPushedTexture("")
  89. Recount.MainWindow.LeftButton:SetHighlightTexture("")
  90. Recount.MainWindow.LeftButton:SetSize(16, 16)
  91. Recount.MainWindow.LeftButton:FontString("text", C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  92. Recount.MainWindow.LeftButton.text:SetText(T.datacolor.."<")
  93. Recount.MainWindow.LeftButton.text:SetPoint("CENTER", 1, 1)
  94. Recount.MainWindow.LeftButton:SetPoint("RIGHT", Recount.MainWindow.RightButton, "LEFT", -2, 0)
  95. Recount.MainWindow.ResetButton:SetTemplate("Transparent")
  96. Recount.MainWindow.ResetButton:SetNormalTexture("")
  97. Recount.MainWindow.ResetButton:SetPushedTexture("")
  98. Recount.MainWindow.ResetButton:SetHighlightTexture("")
  99. Recount.MainWindow.ResetButton:FontString("text", C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  100. Recount.MainWindow.ResetButton.text:SetText(T.datacolor.."R")
  101. Recount.MainWindow.ResetButton.text:SetPoint("CENTER", 1, 1)
  102. Recount.MainWindow.ResetButton:SetPoint("RIGHT", Recount.MainWindow.LeftButton, "LEFT", -2, 0)
  103. Recount.MainWindow.FileButton:SetTemplate("Transparent")
  104. Recount.MainWindow.FileButton:SetNormalTexture("")
  105. Recount.MainWindow.FileButton:SetPushedTexture("")
  106. Recount.MainWindow.FileButton:SetHighlightTexture("")
  107. Recount.MainWindow.FileButton:FontString("text", C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  108. Recount.MainWindow.FileButton.text:SetText(T.datacolor.."F")
  109. Recount.MainWindow.FileButton.text:SetPoint("CENTER", 1, 1)
  110. Recount.MainWindow.FileButton:SetPoint("RIGHT", Recount.MainWindow.ResetButton, "LEFT", -2, 0)
  111. Recount.MainWindow.ConfigButton:SetTemplate("Transparent")
  112. Recount.MainWindow.ConfigButton:SetNormalTexture("")
  113. Recount.MainWindow.ConfigButton:SetPushedTexture("")
  114. Recount.MainWindow.ConfigButton:SetHighlightTexture("")
  115. Recount.MainWindow.ConfigButton:FontString("text", C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  116. Recount.MainWindow.ConfigButton.text:SetText(T.datacolor.."C")
  117. Recount.MainWindow.ConfigButton.text:SetPoint("CENTER", 1, 1)
  118. Recount.MainWindow.ConfigButton:SetPoint("RIGHT", Recount.MainWindow.FileButton, "LEFT", -2, 0)
  119. Recount.MainWindow.ReportButton:SetTemplate("Transparent")
  120. Recount.MainWindow.ReportButton:SetNormalTexture("")
  121. Recount.MainWindow.ReportButton:SetPushedTexture("")
  122. Recount.MainWindow.ReportButton:SetHighlightTexture("")
  123. Recount.MainWindow.ReportButton:FontString("text", C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  124. Recount.MainWindow.ReportButton.text:SetText(T.datacolor.."S")
  125. Recount.MainWindow.ReportButton.text:SetPoint("CENTER", 1, 1)
  126. Recount.MainWindow.ReportButton:SetPoint("RIGHT", Recount.MainWindow.ConfigButton, "LEFT", -2, 0)
  127. if C["Addon_Skins"].embedright == "Recount" then
  128. local Recount_Skin = CreateFrame("Frame")
  129. Recount_Skin:RegisterEvent("PLAYER_ENTERING_WORLD")
  130. Recount_Skin:SetScript("OnEvent", function(self)
  131. self:UnregisterAllEvents()
  132. self = nil
  133. Recount_MainWindow:ClearAllPoints()
  134. Recount_MainWindow:SetPoint("TOPLEFT", TukuiChatBackgroundRight,"TOPLEFT", 0, 7)
  135. Recount_MainWindow:SetPoint("BOTTOMRIGHT", TukuiChatBackgroundRight,"BOTTOMRIGHT", 0, 0)
  136. Recount.db.profile.FrameStrata = "3-MEDIUM"
  137. Recount.db.profile.MainWindowWidth = (TukuiChatBackgroundRight:GetWidth() - 4)
  138. end)
  139. if TukuiTabsRightBackground then
  140. local button = CreateFrame('Button', 'RecountToggleSwitch', TukuiTabsRightBackground)
  141. button:Width(90)
  142. button:Height(TukuiTabsRightBackground:GetHeight() - 4)
  143. button:Point("CENTER", TukuiTabsRightBackground, "CENTER", 2, 0)
  144. button.tex = button:CreateTexture(nil, 'OVERLAY')
  145. button.tex:SetTexture([[Interface\AddOns\Tukui\medias\textures\addons_toggle.tga]])
  146. button.tex:Point('TOPRIGHT', -2, 0)
  147. button.tex:Height(button:GetHeight() - 4)
  148. button.tex:Width(16)
  149. button:FontString(nil, C.media.pixelfont, C["datatext"].fontsize +1, "MONOCHROMEOUTLINE")
  150. button.text:SetPoint('RIGHT', button.tex, 'LEFT')
  151. button.text:SetTextColor(unpack(C["media"].datacolor))
  152. button:SetScript('OnEnter', function(self) button.text:SetText(L.addons_toggle..' Recount') end)
  153. button:SetScript('OnLeave', function(self) self.tex:Point('TOPRIGHT', -2, 0); button.text:SetText(nil) end)
  154. button:SetScript('OnMouseDown', function(self) self.tex:Point('TOPRIGHT', -4, -4) end)
  155. button:SetScript('OnMouseUp', function(self) self.tex:Point('TOPRIGHT', -2, -2) end)
  156. button:SetScript('OnClick', function(self) ToggleFrame(Recount_MainWindow) end)
  157. end
  158. if C["Addon_Skins"].embedrighttoggle == true then
  159. TukuiChatBackgroundRight:HookScript("OnShow", function() Recount_MainWindow:Hide() end)
  160. TukuiChatBackgroundRight:HookScript("OnHide", function() Recount_MainWindow:Show() end)
  161. end
  162. end