PageRenderTime 104ms CodeModel.GetById 50ms app.highlight 14ms RepoModel.GetById 36ms app.codeStats 1ms

/Tukui/modules/addonskins/Recount.lua

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