vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
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.2"):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 ["Charcoal"] = true,
54 ["glaze"] = true,
55 } end)
56  
57 L:RegisterTranslations("koKR", function() return {
58 ["Bars"] = "바",
59  
60 ["Options for the timer bars."] = "Timer 바 옵션 조정.",
61 ["Show the bar anchor frame."] = "바 위치 조정 프레임 보이기.",
62 ["Set the bar scale."] = "바 크기 조절.",
63 ["Group upwards"] = "바 위로 생성",
64 ["Toggle bars grow upwards/downwards from anchor."] = "바 표시 순서를 위/아래로 조정.",
65  
66 ["Timer bars"] = "타이머 바",
67 ["Show anchor"] = "앵커 보이기",
68 ["Grow bars upwards"] = "바 위로 생성",
69 ["Scale"]= "크기",
70 ["Bar scale"] = "바 크기",
71 ["Bars now grow %2$s"] = "바 생성 방향 : %2$s",
72 ["Scale is set to %2$s"] = "크기 설정 : %2$s",
73  
74 ["Up"] = "위",
75 ["Down"] = "아래",
76  
77 ["Test"] = "테스트",
78  
79 ["default"] = "Default",
80 ["smooth"] = "Smooth",
81 ["otravi"] = "Otravi",
82 ["Charcoal"] = "Charcoal",
83 ["glaze"] = "glaze",
84 } end)
85  
86 L:RegisterTranslations("zhCN", function() return {
87 ["Bars"] = "计时条",
88  
89 ["bars"] = "计时条",
90 ["anchor"] = "锚点",
91 ["scale"] = "大小",
92 ["up"] = "上",
93  
94 ["Options for the timer bars."] = "计时条设置/",
95 ["Show the bar anchor frame."] = "显示计时条框体锚点。",
96 ["Set the bar scale."] = "设置计时条缩放比例。",
97 ["Group upwards"] = "向上排列",
98 ["Toggle bars grow upwards/downwards from anchor."] = "切换计时条从锚点向下/向上排列。",
99  
100 ["Timer bars"] = "计时条",
101 ["Show anchor"] = "显示锚点",
102 ["Grow bars upwards"] = "向上延展",
103 ["Scale"] = "缩放",
104 ["Bar scale"] = "计时条缩放",
105  
106 ["Bars now grow %2$s"] = "计时条设置为向%2$s延展。",
107 ["Scale is set to %2$s"] = "缩放比例设置为%2$s",
108  
109 ["Up"] = "上",
110 ["Down"] = "下",
111  
112 ["Test"] = "测试",
113 ["Close"] = "关闭",
114  
115 ["Texture"] = "材质",
116 ["Set the texture for the timerbars."] = "为计时条设定材质。",
117  
118 ["default"] = "默认",
119 ["smooth"] = "圆滑",
120 ["otravi"] = "平整",
121 ["Charcoal"] = "炭条纹",
122 ["glaze"] = "釉纹",
123 } end)
124  
125  
126 L:RegisterTranslations("zhTW", function() return {
127 ["Bars"] = "計時條",
128  
129 ["bars"] = "計時條",
130 ["anchor"] = "錨點",
131 ["scale"] = "大小",
132 ["up"] = "上",
133  
134 ["Options for the timer bars."] = "計時條設置",
135 ["Show the bar anchor frame."] = "顯示計時條框架錨點。",
136 ["Set the bar scale."] = "設置計時條縮放比例。",
137 ["Group upwards"] = "向上排列",
138 ["Toggle bars grow upwards/downwards from anchor."] = "切換計時條從錨點向下/向上排列。",
139  
140 ["Timer bars"] = "計時條",
141 ["Show anchor"] = "顯示錨點",
142 ["Grow bars upwards"] = "向上延展",
143 ["Scale"] = "縮放",
144 ["Bar scale"] = "計時條縮放",
145  
146 ["Bars now grow %2$s"] = "計時條設置為向%2$s延展。",
147 ["Scale is set to %2$s"] = "縮放比例設置為%2$s",
148  
149 ["Up"] = "上",
150 ["Down"] = "下",
151  
152 ["Test"] = "測試",
153 ["Close"] = "關閉",
154  
155 ["Texture"] = "材質",
156 ["Set the texture for the timerbars."] = "設定計時條的材質花紋",
157  
158 ["default"] = "預設",
159 ["smooth"] = "平滑",
160 ["otravi"] = "otravi",
161 ["Charcoal"] = "木炭",
162 ["glaze"] = "glaze",
163 } end)
164  
165  
166 L:RegisterTranslations("deDE", function() return {
167 ["Bars"] = "Anzeigebalken",
168  
169 ["bars"] = "balken",
170 ["anchor"] = "verankerung",
171 ["scale"] = "skalierung",
172 ["up"] = "oben",
173  
174 ["Options for the timer bars."] = "Optionen f\195\188r die Timer Anzeigebalken.",
175 ["Show the bar anchor frame."] = "Verankerung der Anzeigebalken anzeigen.",
176 ["Set the bar scale."] = "Skalierung der Anzeigebalken w\195\164hlen.",
177 ["Group upwards"] = "Nach oben fortsetzen",
178 ["Toggle bars grow upwards/downwards from anchor."] = "Anzeigebalken von der Verankerung aus nach oben/unten fortsetzen.",
179  
180 ["Timer bars"] = "Timer Anzeigebalken",
181 ["Show anchor"] = "Verankerung anzeigen",
182 ["Grow bars upwards"] = "Anzeigebalken nach oben fortsetzen",
183 ["Scale"] = "Skalierung",
184 ["Bar scale"] = "Anzeigebalken Skalierung",
185  
186 ["Bars now grow %2$s"] = "Anzeigebalken werden nun fortgesetzt nach: %2$s",
187 ["Scale is set to %2$s"] = "Skalierung jetzt: %2$s",
188  
189 ["Up"] = "oben",
190 ["Down"] = "unten",
191  
192 ["Test"] = "Test",
193 ["Close"] = "Schlie\195\159en",
194  
195 ["default"] = "Default",
196 ["smooth"] = "Smooth",
197 ["otravi"] = "Otravi",
198 ["Charcoal"] = "Charcoal",
199 ["Texture"] = "Textur",
200 ["Set the texture for the timerbars."] = "Textur der Anzeigebalken w\195\164hlen.",
201  
202 ["default"] = "vorgabe",
203 ["smooth"] = "glatt",
204 ["otravi"] = "otravi",
205 ["Charcoal"] = "Charcoa",
206 ["glaze"] = "glaze",
207 } end)
208  
209 L:RegisterTranslations("frFR", function() return {
210 ["Bars"] = "Barres",
211  
212 ["Options for the timer bars."] = "Options concernant les barres temporelles.",
213 ["Show the bar anchor frame."] = "Affiche l'ancre du cadre des barres.",
214 ["Set the bar scale."] = "Détermine la taille des barres.",
215 ["Group upwards"] = "Ajouter vers le haut",
216 ["Toggle bars grow upwards/downwards from anchor."] = "Ajoute les nouvelles barres soit en haut de l'ancre, soit en bas de l'ancre.",
217  
218 ["Timer bars"] = "Barres temporelles",
219 ["Show anchor"] = "Afficher l'ancre",
220 ["Grow bars upwards"] = "Ajouter barres vers le haut",
221 ["Scale"] = "Taille",
222 ["Bar scale"] = "Taille des barres",
223  
224 ["Bars now grow %2$s"] = "Les barres s'ajoutent désormais vers le %2$s.",
225 ["Scale is set to %2$s"] = "La taille est désormais définie à %2$s.",
226  
227 ["Up"] = "haut",
228 ["Down"] = "bas",
229  
230 ["Test"] = "Test",
231 ["Close"] = "Fermer",
232  
233 ["Texture"] = "Texture",
234 ["Set the texture for the timerbars."] = "Détermine la texture des barres temporelles.",
235  
236 ["default"] = "défaut",
237 ["smooth"] = "smooth",
238 ["otravi"] = "otravi",
239 ["Charcoal"] = "Charcoal",
240 ["glaze"] = "glaze",
241 } end)
242  
243 ----------------------------------
244 -- Module Declaration --
245 ----------------------------------
246  
247 BigWigsBars = BigWigs:NewModule(L["Bars"])
248 BigWigsBars.revision = tonumber(string.sub("$Revision: 13134 $", 12, -3))
249 BigWigsBars.defaultDB = {
250 growup = false,
251 scale = 1.0,
252 texture = L["default"],
253 }
254 BigWigsBars.consoleCmd = L["bars"]
255 BigWigsBars.consoleOptions = {
256 type = "group",
257 name = L["Bars"],
258 desc = L["Options for the timer bars."],
259 args = {
260 [L["anchor"]] = {
261 type = "execute",
262 name = L["Show anchor"],
263 desc = L["Show the bar anchor frame."],
264 func = function() BigWigsBars:BigWigs_ShowAnchors() end,
265 },
266 [L["up"]] = {
267 type = "toggle",
268 name = L["Group upwards"],
269 desc = L["Toggle bars grow upwards/downwards from anchor."],
270 get = function() return BigWigsBars.db.profile.growup end,
271 set = function(v) BigWigsBars.db.profile.growup = v end,
272 message = L["Bars now grow %2$s"],
273 current = L["Bars now grow %2$s"],
274 map = {[true] = L["Up"], [false] = L["Down"]},
275 },
276 [L["scale"]] = {
277 type = "range",
278 name = L["Bar scale"],
279 desc = L["Set the bar scale."],
280 min = 0.2,
281 max = 2.0,
282 step = 0.1,
283 get = function() return BigWigsBars.db.profile.scale end,
284 set = function(v) BigWigsBars.db.profile.scale = v end,
285 },
286 [L["Texture"]] = {
287 type = "text",
288 name = L["Texture"],
289 desc = L["Set the texture for the timerbars."],
290 get = function() return BigWigsBars.db.profile.texture end,
291 set = function(v) BigWigsBars.db.profile.texture = v end,
292 validate = { L["default"], L["otravi"], L["smooth"], L["Charcoal"], L["glaze"] },
293 }
294 },
295 }
296  
297  
298 ------------------------------
299 -- Initialization --
300 ------------------------------
301  
302 function BigWigsBars:OnEnable()
303 if not self.db.profile.texture then self.db.profile.texture = L["default"] end
304 self:SetupFrames()
305 self:RegisterEvent("BigWigs_ShowAnchors")
306 self:RegisterEvent("BigWigs_HideAnchors")
307 self:RegisterEvent("BigWigs_StartBar")
308 self:RegisterEvent("BigWigs_StopBar")
309 end
310  
311  
312 ------------------------------
313 -- Event Handlers --
314 ------------------------------
315  
316 function BigWigsBars:BigWigs_ShowAnchors()
317 self.frames.anchor:Show()
318 end
319  
320  
321 function BigWigsBars:BigWigs_HideAnchors()
322 self.frames.anchor:Hide()
323 end
324  
325 function BigWigsBars:BigWigs_StartBar(module, text, time, icon, otherc, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
326 if not text or not time then return end
327 local id = "BigWigsBar "..text
328 local u = self.db.profile.growup
329  
330 -- yes we try and register every time, we also set the point every time since people can change their mind midbar.
331 module:RegisterCandyBarGroup("BigWigsGroup")
332 module:SetCandyBarGroupPoint("BigWigsGroup", u and "BOTTOM" or "TOP", self.frames.anchor, u and "TOP" or "BOTTOM", 0, 0)
333 module:SetCandyBarGroupGrowth("BigWigsGroup", u)
334  
335 local bc, balpha, txtc
336 if BigWigsColors and type(BigWigsColors) == "table" then
337 if type(otherc) ~= "boolean" or not otherc then c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 = BigWigsColors:BarColor(time) end
338 bc, balpha, txtc = BigWigsColors.db.profile.bgc, BigWigsColors.db.profile.bga, BigWigsColors.db.profile.txtc
339 end
340  
341 module:RegisterCandyBar(id, time, text, icon, c1, c2, c3, c4, c5, c6, c8, c9, c10)
342 module:RegisterCandyBarWithGroup(id, "BigWigsGroup")
343 local texture = "Interface\\AddOns\\BigWigs\\Textures\\" .. (L:HasReverseTranslation(self.db.profile.texture) and L:GetReverseTranslation( self.db.profile.texture ) or "default")
344 module:SetCandyBarTexture( id, texture )
345 if bc then module:SetCandyBarBackgroundColor(id, bc, balpha) end
346 if txtc then module:SetCandyBarTextColor(id, txtc) end
347  
348 module:SetCandyBarScale(id, self.db.profile.scale or 1)
349 module:SetCandyBarFade(id, .5)
350 module:StartCandyBar(id, true)
351 end
352  
353 function BigWigsBars:BigWigs_StopBar(module, text)
354 if not text then return end
355 module:UnregisterCandyBar("BigWigsBar "..text)
356 end
357  
358 ------------------------------
359 -- Slash Handlers --
360 ------------------------------
361  
362 function BigWigsBars:SetScale(msg, supressreport)
363 local scale = tonumber(msg)
364 if scale and scale >= minscale and scale <= maxscale then
365 self.db.profile.scale = scale
366 if not supressreport then self.core:Print(L["Scale is set to %s"], scale) end
367 end
368 end
369  
370 function BigWigsBars:ToggleUp(supressreport)
371 self.db.profile.growup = not self.db.profile.growup
372 local t = self.db.profile.growup
373 if not supressreport then self.core:Print(L["Bars now grow %s"], (t and L["Up"] or L["Down"])) end
374 end
375  
376  
377 ------------------------------
378 -- Create the Anchor --
379 ------------------------------
380  
381 function BigWigsBars:SetupFrames()
382 local f, t
383  
384 f, _, _ = GameFontNormal:GetFont()
385  
386 self.frames = {}
387 self.frames.anchor = CreateFrame("Frame", "BigWigsBarAnchor", UIParent)
388 self.frames.anchor.owner = self
389 self.frames.anchor:Hide()
390  
391 self.frames.anchor:SetWidth(175)
392 self.frames.anchor:SetHeight(75)
393 self.frames.anchor:SetBackdrop({
394 bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", tile = true, tileSize = 16,
395 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16,
396 insets = {left = 4, right = 4, top = 4, bottom = 4},
397 })
398 self.frames.anchor:SetBackdropBorderColor(.5, .5, .5)
399 self.frames.anchor:SetBackdropColor(0,0,0)
400 self.frames.anchor:ClearAllPoints()
401 self.frames.anchor:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
402 self.frames.anchor:EnableMouse(true)
403 self.frames.anchor:RegisterForDrag("LeftButton")
404 self.frames.anchor:SetMovable(true)
405 self.frames.anchor:SetScript("OnDragStart", function() this:StartMoving() end)
406 self.frames.anchor:SetScript("OnDragStop", function() this:StopMovingOrSizing() this.owner:SavePosition() end)
407  
408  
409 self.frames.cfade = self.frames.anchor:CreateTexture(nil, "BORDER")
410 self.frames.cfade:SetWidth(169)
411 self.frames.cfade:SetHeight(25)
412 self.frames.cfade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
413 self.frames.cfade:SetPoint("TOP", self.frames.anchor, "TOP", 0, -4)
414 self.frames.cfade:SetBlendMode("ADD")
415 self.frames.cfade:SetGradientAlpha("VERTICAL", .1, .1, .1, 0, .25, .25, .25, 1)
416 self.frames.anchor.Fade = self.frames.fade
417  
418 self.frames.cheader = self.frames.anchor:CreateFontString(nil,"OVERLAY")
419 self.frames.cheader:SetFont(f, 14)
420 self.frames.cheader:SetWidth(150)
421 self.frames.cheader:SetText(L["Bars"])
422 self.frames.cheader:SetTextColor(1, .8, 0)
423 self.frames.cheader:ClearAllPoints()
424 self.frames.cheader:SetPoint("TOP", self.frames.anchor, "TOP", 0, -10)
425  
426 self.frames.leftbutton = CreateFrame("Button", nil, self.frames.anchor)
427 self.frames.leftbutton.owner = self
428 self.frames.leftbutton:SetWidth(40)
429 self.frames.leftbutton:SetHeight(25)
430 self.frames.leftbutton:SetPoint("RIGHT", self.frames.anchor, "CENTER", -10, -15)
431 self.frames.leftbutton:SetScript( "OnClick", function() self:TriggerEvent("BigWigs_Test") end )
432  
433  
434 t = self.frames.leftbutton:CreateTexture()
435 t:SetWidth(50)
436 t:SetHeight(32)
437 t:SetPoint("CENTER", self.frames.leftbutton, "CENTER")
438 t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up")
439 t:SetTexCoord(0, 0.625, 0, 0.6875)
440 self.frames.leftbutton:SetNormalTexture(t)
441  
442 t = self.frames.leftbutton:CreateTexture(nil, "BACKGROUND")
443 t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down")
444 t:SetTexCoord(0, 0.625, 0, 0.6875)
445 t:SetAllPoints(self.frames.leftbutton)
446 self.frames.leftbutton:SetPushedTexture(t)
447  
448 t = self.frames.leftbutton:CreateTexture()
449 t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Highlight")
450 t:SetTexCoord(0, 0.625, 0, 0.6875)
451 t:SetAllPoints(self.frames.leftbutton)
452 t:SetBlendMode("ADD")
453 self.frames.leftbutton:SetHighlightTexture(t)
454 self.frames.leftbuttontext = self.frames.leftbutton:CreateFontString(nil,"OVERLAY")
455 self.frames.leftbuttontext:SetFontObject(GameFontHighlight)
456 self.frames.leftbuttontext:SetText(L["Test"])
457 self.frames.leftbuttontext:SetAllPoints(self.frames.leftbutton)
458  
459 self.frames.rightbutton = CreateFrame("Button", nil, self.frames.anchor)
460 self.frames.rightbutton.owner = self
461 self.frames.rightbutton:SetWidth(40)
462 self.frames.rightbutton:SetHeight(25)
463 self.frames.rightbutton:SetPoint("LEFT", self.frames.anchor, "CENTER", 10, -15)
464 self.frames.rightbutton:SetScript( "OnClick", function() self:BigWigs_HideAnchors() end )
465  
466  
467 t = self.frames.rightbutton:CreateTexture()
468 t:SetWidth(50)
469 t:SetHeight(32)
470 t:SetPoint("CENTER", self.frames.rightbutton, "CENTER")
471 t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up")
472 t:SetTexCoord(0, 0.625, 0, 0.6875)
473 self.frames.rightbutton:SetNormalTexture(t)
474  
475 t = self.frames.rightbutton:CreateTexture(nil, "BACKGROUND")
476 t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down")
477 t:SetTexCoord(0, 0.625, 0, 0.6875)
478 t:SetAllPoints(self.frames.rightbutton)
479 self.frames.rightbutton:SetPushedTexture(t)
480  
481 t = self.frames.rightbutton:CreateTexture()
482 t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Highlight")
483 t:SetTexCoord(0, 0.625, 0, 0.6875)
484 t:SetAllPoints(self.frames.rightbutton)
485 t:SetBlendMode("ADD")
486 self.frames.rightbutton:SetHighlightTexture(t)
487 self.frames.rightbuttontext = self.frames.rightbutton:CreateFontString(nil,"OVERLAY")
488 self.frames.rightbuttontext:SetFontObject(GameFontHighlight)
489 self.frames.rightbuttontext:SetText(L["Close"])
490 self.frames.rightbuttontext:SetAllPoints(self.frames.rightbutton)
491  
492 self:RestorePosition()
493 end
494  
495  
496 function BigWigsBars:SavePosition()
497 local f = self.frames.anchor
498 local s = f:GetEffectiveScale()
499  
500 self.db.profile.posx = f:GetLeft() * s
501 self.db.profile.posy = f:GetTop() * s
502 end
503  
504  
505 function BigWigsBars:RestorePosition()
506 local x = self.db.profile.posx
507 local y = self.db.profile.posy
508  
509 if not x or not y then return end
510  
511 local f = self.frames.anchor
512 local s = f:GetEffectiveScale()
513  
514 f:ClearAllPoints()
515 f:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x / s, y / s)
516 end