vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local _G = getfenv(0) |
2 | |||
3 | -- if the Debug library is available then use it |
||
4 | if AceLibrary:HasInstance("AceDebug-2.0") then |
||
5 | oSkin = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceDB-2.0", "AceConsole-2.0", "AceHook-2.0", "AceDebug-2.0") |
||
6 | else |
||
7 | oSkin = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceHook-2.0", "AceDB-2.0", "AceConsole-2.0") |
||
8 | function oSkin:Debug() end |
||
9 | end |
||
10 | |||
11 | -- specify where debug messages go |
||
12 | oSkin.debugFrame = ChatFrame5 |
||
13 | |||
14 | function oSkin:OnInitialize() |
||
15 | |||
16 | self:RegisterDB("oSkinDB") |
||
17 | self:Defaults() |
||
18 | self:Options() |
||
19 | |||
20 | self.initialized = {} |
||
21 | |||
22 | self:RegisterChatCommand({"/oskin"}, self.options) |
||
23 | self.OnMenuRequest = self.options |
||
24 | |||
25 | end |
||
26 | |||
27 | function oSkin:OnEnable() |
||
28 | |||
29 | self:RegisterEvent("AceEvent_FullyInitialized") |
||
30 | |||
31 | -- when addon taken out of standby |
||
32 | if AceLibrary("AceEvent-2.0"):IsFullyInitialized() then |
||
33 | self:AceEvent_FullyInitialized() |
||
34 | end |
||
35 | |||
36 | end |
||
37 | |||
38 | local backdrop = { |
||
39 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 16, |
||
40 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, |
||
41 | insets = {left = 4, right = 4, top = 4, bottom = 4}, |
||
42 | } |
||
43 | |||
44 | function oSkin:applySkin(frame, header, bba, ba, fh) |
||
45 | |||
46 | self = oSkin -- for external calls |
||
47 | frame:SetBackdrop(backdrop) |
||
48 | frame:SetBackdropBorderColor(self.db.profile.BackdropBorder.r or .5, self.db.profile.BackdropBorder.g or .5, self.db.profile.BackdropBorder.b or .5, bba or self.db.profile.BackdropBorder.a or 1) |
||
49 | frame:SetBackdropColor(self.db.profile.Backdrop.r or 0, self.db.profile.Backdrop.g or 0, self.db.profile.Backdrop.b or 0, ba or self.db.profile.Backdrop.a or .9) |
||
50 | |||
51 | if not frame.tfade then frame.tfade = frame:CreateTexture(nil, "BORDER") end |
||
52 | frame.tfade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") |
||
53 | |||
54 | frame.tfade:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -4) |
||
55 | if fh then frame.tfade:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -4, -fh) |
||
56 | else frame.tfade:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -4, 4) end |
||
57 | |||
58 | frame.tfade:SetBlendMode("ADD") |
||
59 | frame.tfade:SetGradientAlpha("VERTICAL", .1, .1, .1, 0, .25, .25, .25, 1) |
||
60 | |||
61 | if(header and _G[frame:GetName().."Header"]) then |
||
62 | _G[frame:GetName().."Header"]:Hide() |
||
63 | _G[frame:GetName().."Header"]:SetPoint("TOP", frame, "TOP", 0, 7) |
||
64 | end |
||
65 | |||
66 | end |
||
67 | |||
68 | function oSkin:glazeStatusBar(frame, fi) |
||
69 | |||
70 | if frame:GetFrameType() ~= "StatusBar" then return end |
||
71 | frame:SetStatusBarTexture("Interface\\AddOns\\oSkin\\textures\\glaze") |
||
72 | |||
73 | if fi then |
||
74 | if not frame.tfade then frame.tfade = frame:CreateTexture(nil, "BORDER") end |
||
75 | frame.tfade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") |
||
76 | frame.tfade:SetPoint("TOPLEFT", frame, "TOPLEFT",fi,-fi) |
||
77 | frame.tfade:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT",-fi,fi) |
||
78 | frame.tfade:SetBlendMode("ADD") |
||
79 | frame.tfade:SetGradientAlpha("VERTICAL", .1, .1, .1, 0, .25, .25, .25, 1) |
||
80 | end |
||
81 | |||
82 | end |
||
83 | |||
84 | function oSkin:skinTooltip(frame) |
||
85 | |||
86 | if not frame.tfade then frame.tfade = frame:CreateTexture(nil, "BORDER") end |
||
87 | frame.tfade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") |
||
88 | |||
89 | frame.tfade:SetPoint("TOPLEFT", frame, "TOPLEFT",1,-1) |
||
90 | frame.tfade:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT",-1,1) |
||
91 | |||
92 | frame.tfade:SetBlendMode("ADD") |
||
93 | frame.tfade:SetGradientAlpha("VERTICAL", .1, .1, .1, 0, .25, .25, .25, 1) |
||
94 | |||
95 | frame.tfade:SetPoint("TOPLEFT", frame, "TOPLEFT", 6, -6) |
||
96 | frame.tfade:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -6, -30) |
||
97 | |||
98 | end |
||
99 | |||
100 | function oSkin:removeRegions(frame, regions) |
||
101 | self:Debug("removeRegions: [%s]", frame:GetName() or "???") |
||
102 | |||
103 | if not frame then return end |
||
104 | |||
105 | for i, v in ipairs({ frame:GetRegions() }) do |
||
106 | -- if we have a list, hide the regions in that list |
||
107 | -- otherwise, hide all regions of the frame |
||
108 | if regions then |
||
109 | for _, r in ipairs(regions) do |
||
110 | if r == i then v:SetAlpha(0) break end |
||
111 | end |
||
112 | else |
||
113 | self:Debug("remove region: [%s]", i) |
||
114 | v:SetAlpha(0) |
||
115 | end |
||
116 | end |
||
117 | |||
118 | end |
||
119 | |||
120 | function oSkin:keepRegions(frame, regions) |
||
121 | self:Debug("keepRegions: [%s]", frame:GetName() or "???") |
||
122 | |||
123 | if not frame then return end |
||
124 | |||
125 | for i, v in ipairs({ frame:GetRegions() }) do |
||
126 | -- if we have a list, hide the regions not in that list |
||
127 | local keep = nil |
||
128 | if regions then |
||
129 | for _, r in ipairs(regions) do |
||
130 | if r == i then keep = true break end |
||
131 | end |
||
132 | end |
||
133 | if not keep then |
||
134 | self:Debug("remove region: [%s]", i) |
||
135 | v:SetAlpha(0) |
||
136 | end |
||
137 | end |
||
138 | |||
139 | end |
||
140 | |||
141 | function oSkin:hookDDScript(ddName) |
||
142 | self:Debug("hookDDScript: [%s]", ddName:GetName()) |
||
143 | |||
144 | self:HookScript(ddName, "OnClick", function() |
||
145 | self:Debug(ddName:GetName().."_OnClick") |
||
146 | self.hooks[ddName].OnClick() |
||
147 | self:skinDropDownLists() |
||
148 | end) |
||
149 | |||
150 | end |
||
151 | |||
152 | function oSkin:skinDropDownLists() |
||
153 | -- self:Debug("skinDropDownLists") |
||
154 | |||
155 | for i = 1, UIDROPDOWNMENU_MAXLEVELS do |
||
156 | self:removeRegions(_G["DropDownList"..i]) |
||
157 | _G["DropDownList"..i.."Backdrop"]:Hide() |
||
158 | _G["DropDownList"..i.."MenuBackdrop"]:Hide() |
||
159 | self:applySkin(_G["DropDownList"..i]) |
||
160 | end |
||
161 | |||
162 | end |
||
163 | |||
164 | function oSkin:skinScrollBar(scrollFrame) |
||
165 | -- self:Debug("skinScrollBar: [%s]", scrollFrame:GetName()) |
||
166 | |||
167 | local scrollBar = _G[scrollFrame:GetName().."ScrollBar"] |
||
168 | scrollBar:SetBackdrop({ |
||
169 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 16, |
||
170 | edgeFile = "Interface\\AddOns\\oSkin\\textures\\krsnik", edgeSize = 16, |
||
171 | insets = {left = 4, right = 4, top = 4, bottom = 4}, |
||
172 | }) |
||
173 | scrollBar:SetBackdropBorderColor(.2,.2,.2,1) |
||
174 | scrollBar:SetBackdropColor(.1,.1,.1,1) |
||
175 | |||
176 | end |
||
177 | |||
178 | function oSkin:moveObject(objName, xAdj, xDiff, yAdj, yDiff) |
||
179 | -- self:Debug("moveObject: [%s, %s%s, %s%s]", objName:GetName(), xAdj, xDiff, yAdj, yDiff) |
||
180 | |||
181 | local point, relativeTo, relativePoint, xOfs, yOfs = objName:GetPoint() |
||
182 | -- apply the adjustment |
||
183 | if xAdj == nil then xOffset = xOfs else xOffset = (xAdj == "+" and xOfs + xDiff or xOfs - xDiff) end |
||
184 | if yAdj == nil then yOffset = yOfs else yOffset = (yAdj == "+" and yOfs + yDiff or yOfs - yDiff) end |
||
185 | -- self:Debug("moveObject#2: [%s, %s]", xOffset, yOffset) |
||
186 | |||
187 | objName:ClearAllPoints() |
||
188 | objName:SetPoint(point, relativeTo:GetName(), relativePoint, xOffset, yOffset) |
||
189 | |||
190 | end |