vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | assert( BigWigs, "BigWigs not found!") |
||
3 | |||
4 | |||
5 | ------------------------------ |
||
6 | -- Are you local? -- |
||
7 | ------------------------------ |
||
8 | |||
9 | local L = AceLibrary("AceLocale-2.0"):new("BigWigsBars") |
||
10 | local paint = AceLibrary("PaintChips-2.0") |
||
11 | local minscale, maxscale = 0.25, 2 |
||
12 | |||
13 | |||
14 | ---------------------------- |
||
15 | -- Localization -- |
||
16 | ---------------------------- |
||
17 | |||
18 | L:RegisterTranslations("enUS", function() return { |
||
19 | ["Bars"] = true, |
||
20 | |||
21 | ["bars"] = true, |
||
22 | ["anchor"] = true, |
||
23 | ["scale"] = true, |
||
24 | ["up"] = true, |
||
25 | |||
26 | ["Options for the timer bars."] = true, |
||
27 | ["Show the bar anchor frame."] = true, |
||
28 | ["Set the bar scale."] = true, |
||
29 | ["Group upwards"] = true, |
||
30 | ["Toggle bars grow upwards/downwards from anchor."] = true, |
||
31 | |||
32 | ["Timer bars"] = true, |
||
33 | ["Show anchor"] = true, |
||
34 | ["Grow bars upwards"] = true, |
||
35 | ["Scale"] = true, |
||
36 | ["Bar scale"] = true, |
||
37 | |||
38 | ["Bars now grow %2$s"] = true, |
||
39 | ["Scale is set to %2$s"] = true, |
||
40 | |||
41 | ["Up"] = true, |
||
42 | ["Down"] = true, |
||
43 | |||
44 | ["Test"] = true, |
||
45 | ["Close"] = true, |
||
46 | |||
47 | ["Texture"] = true, |
||
48 | ["Set the texture for the timerbars."] = true, |
||
49 | |||
50 | ["default"] = true, |
||
51 | ["smooth"] = true, |
||
52 | ["otravi"] = true, |
||
53 | } end) |
||
54 | |||
55 | L:RegisterTranslations("koKR", function() return { |
||
56 | ["Bars"] = "바", |
||
57 | |||
58 | ["Options for the timer bars."] = "Timer 바 옵션 조정.", |
||
59 | ["Show the bar anchor frame."] = "바 위치 조정 프레임 보이기.", |
||
60 | ["Set the bar scale."] = "바 크기 조절.", |
||
61 | ["Group upwards"] = "바 위로 생성", |
||
62 | ["Toggle bars grow upwards/downwards from anchor."] = "바 표시 순서를 위/아래로 조정.", |
||
63 | |||
64 | ["Timer bars"] = "타이머 바", |
||
65 | ["Show anchor"] = "앵커 보이기", |
||
66 | ["Grow bars upwards"] = "바 위로 생성", |
||
67 | ["Scale"]= "크기", |
||
68 | ["Bar scale"] = "바 크기", |
||
69 | ["Bars now grow %2$s"] = "바 생성 방향 : %2$s", |
||
70 | ["Scale is set to %2$s"] = "크기 설정 : %2$s", |
||
71 | |||
72 | ["Up"] = "위", |
||
73 | ["Down"] = "아래", |
||
74 | |||
75 | ["Test"] = "테스트", |
||
76 | |||
77 | ["default"] = "Default", |
||
78 | ["smooth"] = "Smooth", |
||
79 | ["otravi"] = "Otravi", |
||
80 | } end) |
||
81 | |||
82 | L:RegisterTranslations("zhCN", function() return { |
||
83 | ["Bars"] = "计时条", |
||
84 | |||
85 | ["Options for the timer bars."] = "计时条设置/", |
||
86 | ["Show the bar anchor frame."] = "显示计时条框体锚点。", |
||
87 | ["Set the bar scale."] = "设置计时条缩放比例。", |
||
88 | ["Group upwards"] = "向上排列", |
||
89 | ["Toggle bars grow upwards/downwards from anchor."] = "切换计时条从锚点向下/向上排列。", |
||
90 | |||
91 | ["Timer bars"] = "计时条", |
||
92 | ["Show anchor"] = "显示锚点", |
||
93 | ["Grow bars upwards"] = "向上延展", |
||
94 | ["Scale"] = "缩放", |
||
95 | ["Bar scale"] = "计时条缩放", |
||
96 | |||
97 | ["Bars now grow %2$s"] = "计时条设置为向%2$s延展。", |
||
98 | ["Scale is set to %2$s"] = "缩放比例设置为%2$s", |
||
99 | |||
100 | ["Up"] = "上", |
||
101 | ["Down"] = "下", |
||
102 | ["Texture"] = "材质", |
||
103 | ["default"] = "默认", |
||
104 | ["smooth"] = "平滑" |
||
105 | } end) |
||
106 | |||
107 | L:RegisterTranslations("deDE", function() return { |
||
108 | ["Bars"] = "Anzeigebalken", |
||
109 | |||
110 | -- ["bars"] = true, |
||
111 | -- ["anchor"] = true, |
||
112 | -- ["scale"] = true, |
||
113 | -- ["up"] = true, |
||
114 | |||
115 | ["Options for the timer bars."] = "Optionen f\195\188r die Timer Anzeigebalken.", |
||
116 | ["Show the bar anchor frame."] = "Zeige die Verankerung der Anzeigebalken.", |
||
117 | ["Set the bar scale."] = "W\195\164hle die Skalierung der Anzeigebalken.", |
||
118 | ["Group upwards"] = "Nach oben fortsetzen", |
||
119 | ["Toggle bars grow upwards/downwards from anchor."] = "Anzeigebalken von der Verankerung aus nach Oben/Unten fortsetzen.", |
||
120 | |||
121 | ["Timer bars"] = "Timer Anzeigebalken", |
||
122 | ["Show anchor"] = "Zeige Verankerung", |
||
123 | ["Grow bars upwards"] = "Anzeigebalken nach oben fortsetzen lassen", |
||
124 | ["Scale"] = "Skalierung", |
||
125 | ["Bar scale"] = "Anzeigebalken Skalierung", |
||
126 | |||
127 | ["Bars now grow %2$s"] = "Anzeigebalken werden nun fortgesetzt nach %2$s", |
||
128 | ["Scale is set to %2$s"] = "Skalierung jetzt %2$s", |
||
129 | |||
130 | ["Up"] = "Oben", |
||
131 | ["Down"] = "Unten", |
||
132 | |||
133 | ["Test"] = "Test", |
||
134 | |||
135 | ["default"] = "Default", |
||
136 | ["smooth"] = "Smooth", |
||
137 | ["otravi"] = "Otravi", |
||
138 | } end) |
||
139 | |||
140 | ---------------------------------- |
||
141 | -- Module Declaration -- |
||
142 | ---------------------------------- |
||
143 | |||
144 | BigWigsBars = BigWigs:NewModule(L"Bars") |
||
145 | BigWigsBars.revision = tonumber(string.sub("$Revision: 12114 $", 12, -3)) |
||
146 | BigWigsBars.defaultDB = { |
||
147 | growup = false, |
||
148 | scale = 1.0, |
||
149 | texture = L["default"], |
||
150 | } |
||
151 | BigWigsBars.consoleCmd = L["bars"] |
||
152 | BigWigsBars.consoleOptions = { |
||
153 | type = "group", |
||
154 | name = L["Bars"], |
||
155 | desc = L["Options for the timer bars."], |
||
156 | args = { |
||
157 | [L["anchor"]] = { |
||
158 | type = "execute", |
||
159 | name = L["Show anchor"], |
||
160 | desc = L["Show the bar anchor frame."], |
||
161 | func = function() BigWigsBars:BigWigs_ShowAnchors() end, |
||
162 | }, |
||
163 | [L["up"]] = { |
||
164 | type = "toggle", |
||
165 | name = L["Group upwards"], |
||
166 | desc = L["Toggle bars grow upwards/downwards from anchor."], |
||
167 | get = function() return BigWigsBars.db.profile.growup end, |
||
168 | set = function(v) BigWigsBars.db.profile.growup = v end, |
||
169 | message = L["Bars now grow %2$s"], |
||
170 | current = L["Bars now grow %2$s"], |
||
171 | map = {[true] = L["Up"], [false] = L["Down"]}, |
||
172 | }, |
||
173 | [L["scale"]] = { |
||
174 | type = "range", |
||
175 | name = L["Bar scale"], |
||
176 | desc = L["Set the bar scale."], |
||
177 | min = 0.2, |
||
178 | max = 2.0, |
||
179 | step = 0.1, |
||
180 | get = function() return BigWigsBars.db.profile.scale end, |
||
181 | set = function(v) BigWigsBars.db.profile.scale = v end, |
||
182 | }, |
||
183 | [L["Texture"]] = { |
||
184 | type = "text", |
||
185 | name = L["Texture"], |
||
186 | desc = L["Set the texture for the timerbars."], |
||
187 | get = function() return BigWigsBars.db.profile.texture end, |
||
188 | set = function(v) BigWigsBars.db.profile.texture = v end, |
||
189 | validate = { L["default"], L["otravi"], L["smooth"] }, |
||
190 | } |
||
191 | }, |
||
192 | } |
||
193 | |||
194 | |||
195 | ------------------------------ |
||
196 | -- Initialization -- |
||
197 | ------------------------------ |
||
198 | |||
199 | function BigWigsBars:OnEnable() |
||
200 | if not self.db.profile.texture then self.db.profile.texture = L["default"] end |
||
201 | self:SetupFrames() |
||
202 | self:RegisterEvent("BigWigs_ShowAnchors") |
||
203 | self:RegisterEvent("BigWigs_HideAnchors") |
||
204 | self:RegisterEvent("BigWigs_StartBar") |
||
205 | self:RegisterEvent("BigWigs_StopBar") |
||
206 | end |
||
207 | |||
208 | |||
209 | ------------------------------ |
||
210 | -- Event Handlers -- |
||
211 | ------------------------------ |
||
212 | |||
213 | function BigWigsBars:BigWigs_ShowAnchors() |
||
214 | self.frames.anchor:Show() |
||
215 | end |
||
216 | |||
217 | |||
218 | function BigWigsBars:BigWigs_HideAnchors() |
||
219 | self.frames.anchor:Hide() |
||
220 | end |
||
221 | |||
222 | function BigWigsBars:BigWigs_StartBar(module, text, time, icon, otherc, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) |
||
223 | if not text or not time then return end |
||
224 | local id = "BigWigsBar "..text |
||
225 | local u = self.db.profile.growup |
||
226 | |||
227 | -- yes we try and register every time, we also set the point every time since people can change their mind midbar. |
||
228 | module:RegisterCandyBarGroup("BigWigsGroup") |
||
229 | module:SetCandyBarGroupPoint("BigWigsGroup", u and "BOTTOM" or "TOP", self.frames.anchor, u and "TOP" or "BOTTOM", 0, 0) |
||
230 | module:SetCandyBarGroupGrowth("BigWigsGroup", u) |
||
231 | |||
232 | if type(otherc) ~= "boolean" or not otherc then c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 = BigWigsColors:BarColor(time) end |
||
233 | local bc, balpha = BigWigsColors.db.profile.bgc, BigWigsColors.db.profile.bga |
||
234 | local txtc = BigWigsColors.db.profile.txtc |
||
235 | |||
236 | module:RegisterCandyBar(id, time, text, icon, c1, c2, c3, c4, c5, c6, c8, c9, c10) |
||
237 | module:RegisterCandyBarWithGroup(id, "BigWigsGroup") |
||
238 | local texture = "Interface\\AddOns\\BigWigs\\Textures\\" .. (L:HasReverseTranslation(self.db.profile.texture) and L:GetReverseTranslation( self.db.profile.texture ) or "default") |
||
239 | module:SetCandyBarTexture( id, texture ) |
||
240 | if bc then module:SetCandyBarBackgroundColor(id, bc, balpha) end |
||
241 | if txtc then module:SetCandyBarTextColor(id, txtc) end |
||
242 | |||
243 | module:SetCandyBarScale(id, self.db.profile.scale or 1) |
||
244 | module:SetCandyBarFade(id, .5) |
||
245 | module:StartCandyBar(id, true) |
||
246 | end |
||
247 | |||
248 | function BigWigsBars:BigWigs_StopBar(module, text) |
||
249 | if not text then return end |
||
250 | module:UnregisterCandyBar("BigWigsBar "..text) |
||
251 | end |
||
252 | |||
253 | ------------------------------ |
||
254 | -- Slash Handlers -- |
||
255 | ------------------------------ |
||
256 | |||
257 | function BigWigsBars:SetScale(msg, supressreport) |
||
258 | local scale = tonumber(msg) |
||
259 | if scale and scale >= minscale and scale <= maxscale then |
||
260 | self.db.profile.scale = scale |
||
261 | if not supressreport then self.core:Print(L["Scale is set to %s"], scale) end |
||
262 | end |
||
263 | end |
||
264 | |||
265 | function BigWigsBars:ToggleUp(supressreport) |
||
266 | self.db.profile.growup = not self.db.profile.growup |
||
267 | local t = self.db.profile.growup |
||
268 | if not supressreport then self.core:Print(L["Bars now grow %s"], (t and L["Up"] or L["Down"])) end |
||
269 | end |
||
270 | |||
271 | |||
272 | ------------------------------ |
||
273 | -- Create the Anchor -- |
||
274 | ------------------------------ |
||
275 | |||
276 | function BigWigsBars:SetupFrames() |
||
277 | local f, t |
||
278 | |||
279 | f, _, _ = GameFontNormal:GetFont() |
||
280 | |||
281 | self.frames = {} |
||
282 | self.frames.anchor = CreateFrame("Frame", "BigWigsBarAnchor", UIParent) |
||
283 | self.frames.anchor.owner = self |
||
284 | self.frames.anchor:Hide() |
||
285 | |||
286 | self.frames.anchor:SetWidth(175) |
||
287 | self.frames.anchor:SetHeight(75) |
||
288 | self.frames.anchor:SetBackdrop({ |
||
289 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", tile = true, tileSize = 16, |
||
290 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, |
||
291 | insets = {left = 4, right = 4, top = 4, bottom = 4}, |
||
292 | }) |
||
293 | self.frames.anchor:SetBackdropBorderColor(.5, .5, .5) |
||
294 | self.frames.anchor:SetBackdropColor(0,0,0) |
||
295 | self.frames.anchor:ClearAllPoints() |
||
296 | self.frames.anchor:SetPoint("CENTER", UIParent, "CENTER", 0, 0) |
||
297 | self.frames.anchor:EnableMouse(true) |
||
298 | self.frames.anchor:RegisterForDrag("LeftButton") |
||
299 | self.frames.anchor:SetMovable(true) |
||
300 | self.frames.anchor:SetScript("OnDragStart", function() this:StartMoving() end) |
||
301 | self.frames.anchor:SetScript("OnDragStop", function() this:StopMovingOrSizing() this.owner:SavePosition() end) |
||
302 | |||
303 | |||
304 | self.frames.cfade = self.frames.anchor:CreateTexture(nil, "BORDER") |
||
305 | self.frames.cfade:SetWidth(169) |
||
306 | self.frames.cfade:SetHeight(25) |
||
307 | self.frames.cfade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") |
||
308 | self.frames.cfade:SetPoint("TOP", self.frames.anchor, "TOP", 0, -4) |
||
309 | self.frames.cfade:SetBlendMode("ADD") |
||
310 | self.frames.cfade:SetGradientAlpha("VERTICAL", .1, .1, .1, 0, .25, .25, .25, 1) |
||
311 | self.frames.anchor.Fade = self.frames.fade |
||
312 | |||
313 | self.frames.cheader = self.frames.anchor:CreateFontString(nil,"OVERLAY") |
||
314 | self.frames.cheader:SetFont(f, 14) |
||
315 | self.frames.cheader:SetWidth(150) |
||
316 | self.frames.cheader:SetText(L["Bars"]) |
||
317 | self.frames.cheader:SetTextColor(1, .8, 0) |
||
318 | self.frames.cheader:ClearAllPoints() |
||
319 | self.frames.cheader:SetPoint("TOP", self.frames.anchor, "TOP", 0, -10) |
||
320 | |||
321 | self.frames.leftbutton = CreateFrame("Button", nil, self.frames.anchor) |
||
322 | self.frames.leftbutton.owner = self |
||
323 | self.frames.leftbutton:SetWidth(40) |
||
324 | self.frames.leftbutton:SetHeight(25) |
||
325 | self.frames.leftbutton:SetPoint("RIGHT", self.frames.anchor, "CENTER", -10, -15) |
||
326 | self.frames.leftbutton:SetScript( "OnClick", function() self:TriggerEvent("BigWigs_Test") end ) |
||
327 | |||
328 | |||
329 | t = self.frames.leftbutton:CreateTexture() |
||
330 | t:SetWidth(50) |
||
331 | t:SetHeight(32) |
||
332 | t:SetPoint("CENTER", self.frames.leftbutton, "CENTER") |
||
333 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up") |
||
334 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
335 | self.frames.leftbutton:SetNormalTexture(t) |
||
336 | |||
337 | t = self.frames.leftbutton:CreateTexture(nil, "BACKGROUND") |
||
338 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down") |
||
339 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
340 | t:SetAllPoints(self.frames.leftbutton) |
||
341 | self.frames.leftbutton:SetPushedTexture(t) |
||
342 | |||
343 | t = self.frames.leftbutton:CreateTexture() |
||
344 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Highlight") |
||
345 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
346 | t:SetAllPoints(self.frames.leftbutton) |
||
347 | t:SetBlendMode("ADD") |
||
348 | self.frames.leftbutton:SetHighlightTexture(t) |
||
349 | self.frames.leftbuttontext = self.frames.leftbutton:CreateFontString(nil,"OVERLAY") |
||
350 | self.frames.leftbuttontext:SetFontObject(GameFontHighlight) |
||
351 | self.frames.leftbuttontext:SetText(L["Test"]) |
||
352 | self.frames.leftbuttontext:SetAllPoints(self.frames.leftbutton) |
||
353 | |||
354 | self.frames.rightbutton = CreateFrame("Button", nil, self.frames.anchor) |
||
355 | self.frames.rightbutton.owner = self |
||
356 | self.frames.rightbutton:SetWidth(40) |
||
357 | self.frames.rightbutton:SetHeight(25) |
||
358 | self.frames.rightbutton:SetPoint("LEFT", self.frames.anchor, "CENTER", 10, -15) |
||
359 | self.frames.rightbutton:SetScript( "OnClick", function() self:BigWigs_HideAnchors() end ) |
||
360 | |||
361 | |||
362 | t = self.frames.rightbutton:CreateTexture() |
||
363 | t:SetWidth(50) |
||
364 | t:SetHeight(32) |
||
365 | t:SetPoint("CENTER", self.frames.rightbutton, "CENTER") |
||
366 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up") |
||
367 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
368 | self.frames.rightbutton:SetNormalTexture(t) |
||
369 | |||
370 | t = self.frames.rightbutton:CreateTexture(nil, "BACKGROUND") |
||
371 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down") |
||
372 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
373 | t:SetAllPoints(self.frames.rightbutton) |
||
374 | self.frames.rightbutton:SetPushedTexture(t) |
||
375 | |||
376 | t = self.frames.rightbutton:CreateTexture() |
||
377 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Highlight") |
||
378 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
379 | t:SetAllPoints(self.frames.rightbutton) |
||
380 | t:SetBlendMode("ADD") |
||
381 | self.frames.rightbutton:SetHighlightTexture(t) |
||
382 | self.frames.rightbuttontext = self.frames.rightbutton:CreateFontString(nil,"OVERLAY") |
||
383 | self.frames.rightbuttontext:SetFontObject(GameFontHighlight) |
||
384 | self.frames.rightbuttontext:SetText(L["Close"]) |
||
385 | self.frames.rightbuttontext:SetAllPoints(self.frames.rightbutton) |
||
386 | |||
387 | self:RestorePosition() |
||
388 | end |
||
389 | |||
390 | |||
391 | function BigWigsBars:SavePosition() |
||
392 | local f = self.frames.anchor |
||
393 | local s = f:GetEffectiveScale() |
||
394 | |||
395 | self.db.profile.posx = f:GetLeft() * s |
||
396 | self.db.profile.posy = f:GetTop() * s |
||
397 | end |
||
398 | |||
399 | |||
400 | function BigWigsBars:RestorePosition() |
||
401 | local x = self.db.profile.posx |
||
402 | local y = self.db.profile.posy |
||
403 | |||
404 | if not x or not y then return end |
||
405 | |||
406 | local f = self.frames.anchor |
||
407 | local s = f:GetEffectiveScale() |
||
408 | |||
409 | f:ClearAllPoints() |
||
410 | f:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x / s, y / s) |
||
411 | end |