vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Name: FuBarPlugin-2.0
3 Revision: $Rev: 9775 $
4 Author: Cameron Kenneth Knight (ckknight@gmail.com)
5 Website: http://wiki.wowace.com/index.php/FuBarPlugin-2.0
6 Documentation: http://wiki.wowace.com/index.php/FuBarPlugin-2.0
7 SVN: svn://svn.wowace.com/root/branches/FuBar/FuBarPlugin-2.0/FuBarPlugin-2.0/
8 Description: Plugin for FuBar.
9 Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0, Tablet-2.0, Dewdrop-2.0
10 ]]
11  
12 local MAJOR_VERSION = "FuBarPlugin-2.0"
13 local MINIMAPCONTAINER_MAJOR_VERSION = "FuBarPlugin-MinimapContainer-2.0"
14 local MINOR_VERSION = "$Revision: 9775 $"
15  
16 -- This ensures the code is only executed if the libary doesn't already exist, or is a newer version
17 if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end
18 if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
19  
20 if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0.") end
21  
22 local AceEvent = AceLibrary:HasInstance("AceEvent-2.0") and AceLibrary("AceEvent-2.0")
23 local Tablet = AceLibrary:HasInstance("Tablet-2.0") and AceLibrary("Tablet-2.0")
24 local Dewdrop = AceLibrary:HasInstance("Dewdrop-2.0") and AceLibrary("Dewdrop-2.0")
25  
26 local epsilon = 1e-5
27 local _G = getfenv(0)
28  
29 local FuBarPlugin = AceLibrary("AceOO-2.0").Mixin {
30 "GetTitle",
31 "GetName",
32 "GetCategory",
33 "SetFontSize",
34 "GetFrame",
35 "Show",
36 "Hide",
37 "GetPanel",
38 "IsTextColored",
39 "ToggleTextColored",
40 "IsMinimapAttached",
41 "ToggleMinimapAttached",
42 "Update",
43 "UpdateDisplay",
44 "UpdateData",
45 "UpdateText",
46 "UpdateTooltip",
47 "SetIcon",
48 "GetIcon",
49 "CheckWidth",
50 "SetText",
51 "GetText",
52 "IsIconShown",
53 "ToggleIconShown",
54 "ShowIcon",
55 "HideIcon",
56 "IsTextShown",
57 "ToggleTextShown",
58 "ShowText",
59 "HideText",
60 "IsTooltipDetached",
61 "ToggleTooltipDetached",
62 "DetachTooltip",
63 "ReattachTooltip",
64 "GetDefaultPosition",
65 "SetPanel",
66 "IsLoadOnDemand",
67 "IsDisabled",
68 "CreateBasicPluginFrame",
69 "CreatePluginChildFrame",
70 "OpenMenu",
71 "AddImpliedMenuOptions",
72 }
73  
74 local good = nil
75 local function CheckFuBar()
76 if not good then
77 good = FuBar and tonumber(string.sub(FuBar.version, 1, 3)) and tonumber(string.sub(FuBar.version, 1, 3)) >= 2 and true
78 end
79 return good
80 end
81  
82 function FuBarPlugin:GetTitle()
83 local name = self.title or self.name
84 FuBarPlugin:assert(name, "You must provide self.title or self.name")
85 local _,_,title = string.find(name, "FuBar %- (.-)%s*$")
86 if not title then
87 title = name
88 end
89 return (string.gsub(string.gsub(title, "|c%x%x%x%x%x%x%x%x", ""), "|r", ""))
90 end
91  
92 function FuBarPlugin:GetName()
93 return self.name
94 end
95  
96 function FuBarPlugin:GetCategory()
97 return self.category or "Other"
98 end
99  
100 function FuBarPlugin:GetFrame()
101 return self.frame
102 end
103  
104 function FuBarPlugin:GetPanel()
105 return self.panel
106 end
107  
108 function FuBarPlugin:IsTextColored()
109 return not self.db or not self.db.profile or not self.db.profile.uncolored
110 end
111  
112 function FuBarPlugin:ToggleTextColored()
113 FuBarPlugin:assert(self.db, "Cannot change text color if self.db is not available. (" .. self:GetTitle() .. ")")
114 self.db.profile.uncolored = not self.db.profile.uncolored or nil
115 self:UpdateText()
116 end
117  
118 function FuBarPlugin:ToggleMinimapAttached()
119 if CheckFuBar() and not self.cannotAttachToMinimap then
120 local value = self:IsMinimapAttached()
121 if value then
122 if self.panel then
123 self.panel:RemovePlugin(self)
124 end
125 FuBar:GetPanel(1):AddPlugin(self, nil, self.defaultPosition)
126 else
127 if self.panel then
128 self.panel:RemovePlugin(self)
129 end
130 AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION):AddPlugin(self)
131 end
132 end
133 Dewdrop:Close()
134 end
135  
136 function FuBarPlugin:IsMinimapAttached()
137 if not CheckFuBar() then
138 return true
139 end
140 return self.panel == AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION)
141 end
142  
143 function FuBarPlugin:Update()
144 self:UpdateData()
145 self:UpdateText()
146 self:UpdateTooltip()
147 end
148  
149 function FuBarPlugin:UpdateDisplay()
150 self:UpdateText()
151 self:UpdateTooltip()
152 end
153  
154 function FuBarPlugin:UpdateData()
155 if type(self.OnDataUpdate) == "function" then
156 if not self:IsDisabled() then
157 self:OnDataUpdate()
158 end
159 end
160 end
161  
162 function FuBarPlugin:UpdateText()
163 if type(self.OnTextUpdate) == "function" then
164 if not self:IsDisabled() then
165 self:OnTextUpdate()
166 end
167 elseif self:IsTextShown() then
168 self:SetText(self:GetTitle())
169 end
170 end
171  
172 function FuBarPlugin:RegisterTablet()
173 if not Tablet:IsRegistered(self.frame) then
174 if self.db and self.db.profile and not self.db.profile.detachedTooltip then
175 self.db.profile.detachedTooltip = {}
176 end
177 Tablet:Register(self.frame,
178 'children', function()
179 Tablet:SetTitle(self:GetTitle())
180 if type(self.OnTooltipUpdate) == "function" then
181 if not self:IsDisabled() then
182 self:OnTooltipUpdate()
183 end
184 end
185 end,
186 'clickable', self.clickableTooltip,
187 'data', CheckFuBar() and FuBar.db.profile.tooltip or self.db and self.db.profile.detachedTooltip or {},
188 'detachedData', self.db and self.db.profile.detachedTooltip or {},
189 'point', function(frame)
190 if frame:GetTop() > GetScreenHeight() / 2 then
191 local x = frame:GetCenter()
192 if x < GetScreenWidth() / 3 then
193 return "TOPLEFT", "BOTTOMLEFT"
194 elseif x < GetScreenWidth() * 2 / 3 then
195 return "TOP", "BOTTOM"
196 else
197 return "TOPRIGHT", "BOTTOMRIGHT"
198 end
199 else
200 local x = frame:GetCenter()
201 if x < GetScreenWidth() / 3 then
202 return "BOTTOMLEFT", "TOPLEFT"
203 elseif x < GetScreenWidth() * 2 / 3 then
204 return "BOTTOM", "TOP"
205 else
206 return "BOTTOMRIGHT", "TOPRIGHT"
207 end
208 end
209 end,
210 'menu', self.OnMenuRequest and function(level, value, valueN_1, valueN_2, valueN_3, valueN_4)
211 if level == 1 then
212 local name = tostring(self)
213 if not string.find(name, '^table:') then
214 name = string.gsub(name, "|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
215 Dewdrop:AddLine(
216 'text', name,
217 'isTitle', true
218 )
219 end
220 end
221 if type(self.OnMenuRequest) == "function" then
222 self:OnMenuRequest(level, value, true, valueN_1, valueN_2, valueN_3, valueN_4)
223 elseif type(self.OnMenuRequest) == "table" then
224 Dewdrop:FeedAceOptionsTable(self.OnMenuRequest)
225 end
226 end,
227 'hideWhenEmpty', self.tooltipHiddenWhenEmpty
228 )
229 end
230 end
231  
232 function FuBarPlugin:UpdateTooltip()
233 FuBarPlugin.RegisterTablet(self)
234 if self:IsMinimapAttached() and not self:IsTooltipDetached() then
235 Tablet:Refresh(self.minimapFrame)
236 else
237 Tablet:Refresh(self.frame)
238 end
239 end
240  
241 function FuBarPlugin:OnProfileEnable()
242 self:Update()
243 end
244  
245 function FuBarPlugin:Show(panelId)
246 if self.frame:IsShown() or (self.minimapFrame and self.minimapFrame:IsShown()) then
247 return
248 end
249 if panelId ~= false then
250 if self.db then
251 self.db.profile.hidden = nil
252 end
253 end
254 if self.IsActive and not self:IsActive() then
255 self.panelIdTmp = panelId
256 self:ToggleActive()
257 self.panelIdTmp = nil
258 if self.db then
259 self.db.profile.disabled = nil
260 end
261 elseif not self.db or not self.db.profile.hidden then
262 if panelId == 0 or not CheckFuBar() then
263 AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION):AddPlugin(self)
264 else
265 FuBar:ShowPlugin(self, panelId or self.panelIdTmp)
266 end
267 if not self:IsTextShown() then
268 self.textFrame:SetText("")
269 self.textFrame:SetWidth(epsilon)
270 self.textFrame:Hide()
271 end
272 if not self:IsIconShown() then
273 self.iconFrame:SetWidth(epsilon)
274 self.iconFrame:Hide()
275 end
276 self:Update()
277 end
278 end
279  
280 function FuBarPlugin:Hide()
281 if not self.frame:IsShown() and (not self.minimapFrame or not self.minimapFrame:IsShown()) then
282 return
283 end
284 if self.hideWithoutStandby then
285 if self.db then
286 self.db.profile.hidden = true
287 end
288 end
289 if not self.hideWithoutStandby then
290 if self.db and not self.overrideTooltip and not self.cannotDetachTooltip and self:IsTooltipDetached() and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then
291 self:ReattachTooltip()
292 self.db.profile.detachedTooltip.detached = true
293 end
294 if self.IsActive and self:IsActive() and self.ToggleActive and (not CheckFuBar() or not FuBar:IsChangingProfile()) then
295 self:ToggleActive()
296 end
297 end
298 if self.panel then
299 self.panel:RemovePlugin(self)
300 end
301 self.frame:Hide()
302 if self.minimapFrame then
303 self.minimapFrame:Hide()
304 end
305  
306 if Dewdrop:IsOpen(self.frame) or (self.minimapFrame and Dewdrop:IsOpen(self.minimapFrame)) then
307 Dewdrop:Close()
308 end
309 end
310  
311 function FuBarPlugin:SetIcon(path)
312 if not path then
313 return
314 end
315 FuBarPlugin:argCheck(path, 2, "string", "boolean")
316 FuBarPlugin:assert(self.hasIcon, "Cannot set icon unless self.hasIcon is set. (" .. self:GetTitle() .. ")")
317 if not self.iconFrame then
318 return
319 end
320 if type(path) ~= "string" then
321 path = format("Interface\\AddOns\\%s\\icon", self.folderName)
322 elseif not string.find(path, '^Interface[\\/]') then
323 path = format("Interface\\AddOns\\%s\\%s", self.folderName, path)
324 end
325 if string.sub(path, 1, 16) == "Interface\\Icons\\" then
326 self.iconFrame:SetTexCoord(0.05, 0.95, 0.05, 0.95)
327 else
328 self.iconFrame:SetTexCoord(0, 1, 0, 1)
329 end
330 self.iconFrame:SetTexture(path)
331 if self.minimapIcon then
332 if string.sub(path, 1, 16) == "Interface\\Icons\\" then
333 self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
334 else
335 self.minimapIcon:SetTexCoord(0, 1, 0, 1)
336 end
337 self.minimapIcon:SetTexture(path)
338 end
339 end
340  
341 function FuBarPlugin:GetIcon()
342 if self.hasIcon then
343 return self.iconFrame:GetTexture()
344 end
345 end
346  
347 function FuBarPlugin:CheckWidth(force)
348 FuBarPlugin:argCheck(force, 2, "boolean", "nil")
349 if (self.iconFrame and self.iconFrame:IsShown()) or (self.textFrame and self.textFrame:IsShown()) then
350 if (self.db and self.db.profile and not self:IsIconShown()) or not self.hasIcon then
351 self.iconFrame:SetWidth(epsilon)
352 end
353 local width
354 if not self.hasNoText then
355 self.textFrame:SetHeight(0)
356 self.textFrame:SetWidth(500)
357 width = self.textFrame:GetStringWidth() + 1
358 self.textFrame:SetWidth(width)
359 self.textFrame:SetHeight(self.textFrame:GetHeight())
360 end
361 if self.hasNoText or not self.textFrame:IsShown() then
362 self.frame:SetWidth(self.iconFrame:GetWidth())
363 if self.panel and self.panel:GetPluginSide(self) == "CENTER" then
364 self.panel:UpdateCenteredPosition()
365 end
366 elseif force or not self.textWidth or self.textWidth < width or self.textWidth - 8 > width then
367 self.textWidth = width
368 self.textFrame:SetWidth(width)
369 if self.iconFrame and self.iconFrame:IsShown() then
370 self.frame:SetWidth(width + self.iconFrame:GetWidth())
371 else
372 self.frame:SetWidth(width)
373 end
374 if self.panel and self.panel:GetPluginSide(self) == "CENTER" then
375 self.panel:UpdateCenteredPosition()
376 end
377 end
378 end
379 end
380  
381 function FuBarPlugin:SetText(text)
382 if not self.textFrame then
383 return
384 end
385 FuBarPlugin:assert(not self.hasNoText, "Cannot set text if self.hasNoText has been set. (" .. self:GetTitle() .. ")")
386 FuBarPlugin:argCheck(text, 2, "string", "number")
387 if text == "" then
388 if self.hasIcon then
389 self:ShowIcon()
390 else
391 text = self:GetTitle()
392 end
393 end
394 if not self:IsTextColored() then
395 text = string.gsub(text, "|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
396 end
397 self.textFrame:SetText(text)
398 self:CheckWidth()
399 end
400  
401 function FuBarPlugin:GetText()
402 FuBarPlugin:assert(self.textFrame, "Cannot get text without a self.textFrame (" .. self:GetTitle() .. ")")
403 if not self.hasNoText then
404 return self.textFrame:GetText() or ""
405 end
406 end
407  
408 function FuBarPlugin:IsIconShown()
409 if not self.hasIcon then
410 return false
411 elseif self.hasNoText then
412 return true
413 elseif not self.db then
414 return true
415 elseif self.db.profile.showIcon == nil then
416 return true
417 else
418 return (self.db.profile.showIcon == 1 or self.db.profile.showIcon == true) and true or false
419 end
420 end
421  
422 function FuBarPlugin:ToggleIconShown()
423 FuBarPlugin:assert(self.iconFrame, "Cannot toggle icon without a self.iconFrame (" .. self:GetTitle() .. ")")
424 FuBarPlugin:assert(self.hasIcon, "Cannot show icon unless self.hasIcon is set. (" .. self:GetTitle() .. ")")
425 FuBarPlugin:assert(not self.hasNoText, "Cannot hide icon if self.hasNoText is set. (" .. self:GetTitle() .. ")")
426 FuBarPlugin:assert(self.textFrame, "Cannot hide icon if self.textFrame is not set. (" .. self:GetTitle() .. ")")
427 FuBarPlugin:assert(self.iconFrame, "Cannot hide icon if self.iconFrame is not set. (" .. self:GetTitle() .. ")")
428 FuBarPlugin:assert(self.db, "Cannot hide icon if self.db is not available. (" .. self:GetTitle() .. ")")
429 local value = not self:IsIconShown()
430 self.db.profile.showIcon = value
431 if value then
432 if not self:IsTextShown() and self.textFrame:IsShown() and self.textFrame:GetText() == self:GetTitle() then
433 self.textFrame:Hide()
434 self.textFrame:SetText("")
435 end
436 self.iconFrame:Show()
437 self.iconFrame:SetWidth(self.iconFrame:GetHeight())
438 else
439 if not self.textFrame:IsShown() or not self.textFrame:GetText() then
440 self.textFrame:Show()
441 self.textFrame:SetText(self:GetTitle())
442 end
443 self.iconFrame:Hide()
444 self.iconFrame:SetWidth(epsilon)
445 end
446 self:CheckWidth(true)
447 return value
448 end
449  
450 function FuBarPlugin:ShowIcon()
451 if not self:IsIconShown() then
452 self:ToggleIconShown()
453 end
454 end
455  
456 function FuBarPlugin:HideIcon()
457 if self:IsIconShown() then
458 self:ToggleIconShown()
459 end
460 end
461  
462 function FuBarPlugin:IsTextShown()
463 if self.hasNoText then
464 return false
465 elseif not self.hasIcon then
466 return true
467 elseif not self.db then
468 return true
469 elseif self.db.profile.showText == nil then
470 return true
471 else
472 return (self.db.profile.showText == 1 or self.db.profile.showText == true) and true or false
473 end
474 end
475  
476 function FuBarPlugin:ToggleTextShown()
477 FuBarPlugin:assert(not self.cannotHideText, "Cannot hide text unless self.cannotHideText is unset. (" .. self:GetTitle() .. ")")
478 FuBarPlugin:assert(self.hasIcon, "Cannot show text unless self.hasIcon is set. (" .. self:GetTitle() .. ")")
479 FuBarPlugin:assert(not self.hasNoText, "Cannot hide text if self.hasNoText is set. (" .. self:GetTitle() .. ")")
480 FuBarPlugin:assert(self.textFrame, "Cannot hide text if self.textFrame is not set. (" .. self:GetTitle() .. ")")
481 FuBarPlugin:assert(self.iconFrame, "Cannot hide text if self.iconFrame is not set. (" .. self:GetTitle() .. ")")
482 FuBarPlugin:assert(self.db, "Cannot hide text if self.db is not available. (" .. self:GetTitle() .. ")")
483 local value = not self:IsTextShown()
484 self.db.profile.showText = value
485 if value then
486 self.textFrame:Show()
487 self:UpdateText()
488 else
489 self.textFrame:SetText("")
490 self.textFrame:SetWidth(epsilon)
491 self.textFrame:Hide()
492 if not self:IsIconShown() then
493 DropDownList1:Hide()
494 end
495 self:ShowIcon()
496 end
497 self:CheckWidth(true)
498 return value
499 end
500  
501 function FuBarPlugin:ShowText()
502 if not self:IsTextShown() then
503 self:ToggleTextShown()
504 end
505 end
506  
507 function FuBarPlugin:HideText()
508 if self:IsTextShown() then
509 self:ToggleTextShown()
510 end
511 end
512  
513 function FuBarPlugin:IsTooltipDetached()
514 FuBarPlugin.RegisterTablet(self)
515 return not Tablet:IsAttached(self.frame)
516 end
517  
518 function FuBarPlugin:ToggleTooltipDetached()
519 FuBarPlugin.RegisterTablet(self)
520 if self:IsTooltipDetached() then
521 Tablet:Attach(self.frame)
522 else
523 Tablet:Detach(self.frame)
524 end
525 end
526  
527 function FuBarPlugin:DetachTooltip()
528 FuBarPlugin.RegisterTablet(self)
529 Tablet:Detach(self.frame)
530 end
531  
532 function FuBarPlugin:ReattachTooltip()
533 FuBarPlugin.RegisterTablet(self)
534 Tablet:Attach(self.frame)
535 end
536  
537 function FuBarPlugin:GetDefaultPosition()
538 return self.defaultPosition or "LEFT"
539 end
540  
541 local function IsCorrectPanel(panel)
542 if type(panel) ~= "table" then
543 return false
544 elseif type(panel.AddPlugin) ~= "function" then
545 return false
546 elseif type(panel.RemovePlugin) ~= "function" then
547 return false
548 elseif type(panel.GetNumPlugins) ~= "function" then
549 return false
550 elseif type(panel:GetNumPlugins()) ~= "number" then
551 return false
552 elseif type(panel.GetPlugin) ~= "function" then
553 return false
554 elseif type(panel.HasPlugin) ~= "function" then
555 return false
556 elseif type(panel.GetPluginSide) ~= "function" then
557 return false
558 end
559 return true
560 end
561  
562 function FuBarPlugin:SetPanel(panel)
563 if panel then
564 FuBarPlugin:assert(IsCorrectPanel(panel), "Bad argument #2 to `SetPanel'. Panel does not have the correct API.")
565 end
566 self.panel = panel
567 end
568  
569 function FuBarPlugin:SetFontSize(size)
570 FuBarPlugin:assert(not self.userDefinedFrame, "You must provide a SetFontSize(size) method if you provide your own frame.")
571 if self.hasIcon then
572 FuBarPlugin:assert(self.iconFrame, (self.name and self.name .. ": " or "") .. "No iconFrame found")
573 self.iconFrame:SetWidth(size + 3)
574 self.iconFrame:SetHeight(size + 3)
575 end
576 if not self.hasNoText then
577 FuBarPlugin:assert(self.textFrame, (self.name and self.name .. ": " or "") .. "No textFrame found")
578 local font, _, flags = self.textFrame:GetFont()
579 self.textFrame:SetFont(font, size, flags)
580 end
581 self:CheckWidth()
582 end
583  
584 function FuBarPlugin:IsLoadOnDemand()
585 return IsAddOnLoadOnDemand(self.folderName)
586 end
587  
588 function FuBarPlugin:IsDisabled()
589 return self.IsActive and not self:IsActive() or false
590 end
591  
592 function FuBarPlugin:OnInstanceInit(target)
593 if not AceEvent then
594 self:error(MAJOR_VERSION .. " requires AceEvent-2.0.")
595 elseif not Tablet then
596 self:error(MAJOR_VERSION .. " requires Tablet-2.0.")
597 elseif not Dewdrop then
598 self:error(MAJOR_VERSION .. " requires Dewdrop-2.0.")
599 end
600 self.registry[target] = true
601  
602 local _,_,folderName = string.find(debugstack(6, 1, 0), "\\AddOns\\(.*)\\")
603 target.folderName = folderName
604 self.folderNames[target] = folderName
605 end
606  
607 function FuBarPlugin:CreateBasicPluginFrame(name)
608 local frame = CreateFrame("Button", name, UIParent)
609 frame:SetFrameStrata("HIGH")
610 frame:EnableMouse(true)
611 frame:EnableMouseWheel(true)
612 frame:SetMovable(true)
613 frame:SetWidth(150)
614 frame:SetHeight(24)
615 frame:SetPoint("CENTER", UIParent, "CENTER")
616  
617 frame:SetScript("OnClick", function()
618 if type(self.OnClick) == "function" then
619 self:OnClick(arg1)
620 end
621 end)
622 frame:SetScript("OnDoubleClick", function()
623 if type(self.OnDoubleClick) == "function" then
624 self:OnDoubleClick(arg1)
625 end
626 end)
627 frame:SetScript("OnMouseDown", function()
628 if arg1 == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
629 self:OpenMenu()
630 return
631 else
632 HideDropDownMenu(1)
633 if type(self.OnMouseDown) == "function" then
634 self:OnMouseDown(arg1)
635 end
636 end
637 end)
638 frame:SetScript("OnMouseUp", function()
639 if type(self.OnMouseUp) == "function" then
640 self:OnMouseUp(arg1)
641 end
642 end)
643 frame:SetScript("OnReceiveDrag", function()
644 if type(self.OnReceiveDrag) == "function" then
645 self:OnReceiveDrag()
646 end
647 end)
648 return frame
649 end
650  
651 function FuBarPlugin:CreatePluginChildFrame(frameType, name, parent)
652 FuBarPlugin:assert(self.frame, "You must have self.frame declared in order to add child frames")
653 FuBarPlugin:argCheck(frameType, 1, "string")
654 local child = CreateFrame(frameType, name, parent)
655 if parent then
656 child:SetFrameLevel(parent:GetFrameLevel() + 2)
657 end
658 child:SetScript("OnEnter", function()
659 if self.frame:GetScript("OnEnter") then
660 self.frame:GetScript("OnEnter")()
661 end
662 end)
663 child:SetScript("OnLeave", function()
664 if self.frame:GetScript("OnLeave") then
665 self.frame:GetScript("OnLeave")()
666 end
667 end)
668 if child:HasScript("OnClick") then
669 child:SetScript("OnClick", function()
670 if self.frame:HasScript("OnClick") and self.frame:GetScript("OnClick") then
671 self.frame:GetScript("OnClick")()
672 end
673 end)
674 end
675 if child:HasScript("OnDoubleClick") then
676 child:SetScript("OnDoubleClick", function()
677 if self.frame:HasScript("OnDoubleClick") and self.frame:GetScript("OnDoubleClick") then
678 self.frame:GetScript("OnDoubleClick")()
679 end
680 end)
681 end
682 child:SetScript("OnMouseDown", function()
683 if self.frame:GetScript("OnMouseDown") then
684 self.frame:GetScript("OnMouseDown")()
685 end
686 end)
687 child:SetScript("OnMouseUp", function()
688 if self.frame:GetScript("OnMouseUp") then
689 self.frame:GetScript("OnMouseUp")()
690 end
691 end)
692 child:SetScript("OnReceiveDrag", function()
693 if self.frame:GetScript("OnReceiveDrag") then
694 self.frame:GetScript("OnReceiveDrag")()
695 end
696 end)
697 return child
698 end
699  
700 function FuBarPlugin:OpenMenu(frame)
701 if not frame then
702 frame = self:GetFrame()
703 end
704 if not frame or not self:GetFrame() or Dewdrop:IsOpen(frame) then
705 Dewdrop:Close()
706 return
707 end
708 Tablet:Close()
709  
710 if not Dewdrop:IsRegistered(self:GetFrame()) then
711 if type(self.OnMenuRequest) == "table" and (not self.OnMenuRequest.handler or self.OnMenuRequest.handler == self) and self.OnMenuRequest.type == "group" then
712 Dewdrop:InjectAceOptionsTable(self, self.OnMenuRequest)
713 if self.OnMenuRequest.args and CheckFuBar() and not self.independentProfile then
714 self.OnMenuRequest.args.profile = nil
715 end
716 end
717 Dewdrop:Register(self:GetFrame(),
718 'children', type(self.OnMenuRequest) == "table" and self.OnMenuRequest or function(level, value, valueN_1, valueN_2, valueN_3, valueN_4)
719 if level == 1 then
720 Dewdrop:AddLine(
721 'text', self:GetTitle(),
722 'isTitle', true
723 )
724 end
725  
726 if level == 1 then
727 if self.OnMenuRequest then
728 self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4)
729 end
730  
731 if not self.overrideMenu then
732 if self.MenuSettings then
733 Dewdrop:AddLine()
734 end
735 self:AddImpliedMenuOptions()
736 end
737 else
738 if not self.overrideMenu and self:AddImpliedMenuOptions() then
739 else
740 if self.OnMenuRequest then
741 self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4)
742 end
743 end
744 end
745 if level == 1 then
746 Dewdrop:AddLine(
747 'text', CLOSE,
748 'func', Dewdrop.Close,
749 'arg1', Dewdrop
750 )
751 end
752 end,
753 'point', function(frame)
754 local x, y = frame:GetCenter()
755 local leftRight
756 if x < GetScreenWidth() / 2 then
757 leftRight = "LEFT"
758 else
759 leftRight = "RIGHT"
760 end
761 if y < GetScreenHeight() / 2 then
762 return "BOTTOM" .. leftRight, "TOP" .. leftRight
763 else
764 return "TOP" .. leftRight, "BOTTOM" .. leftRight
765 end
766 end,
767 'dontHook', true
768 )
769 end
770 if frame == self:GetFrame() then
771 Dewdrop:Open(self:GetFrame())
772 else
773 Dewdrop:Open(frame, self:GetFrame())
774 end
775 end
776  
777 local impliedMenuOptions
778 function FuBarPlugin:AddImpliedMenuOptions(level)
779 FuBarPlugin:argCheck(level, 2, "number", "nil")
780 if not impliedMenuOptions then
781 impliedMenuOptions = {}
782 end
783 if not impliedMenuOptions[self] then
784 impliedMenuOptions[self] = { type = 'group', args = {} }
785 Dewdrop:InjectAceOptionsTable(self, impliedMenuOptions[self])
786 if impliedMenuOptions[self].args and CheckFuBar() and not self.independentProfile then
787 impliedMenuOptions[self].args.profile = nil
788 end
789 end
790 return Dewdrop:FeedAceOptionsTable(impliedMenuOptions[self], level and level - 1)
791 end
792  
793 function FuBarPlugin.OnEmbedInitialize(FuBarPlugin, self)
794 if not self.frame then
795 local name = "FuBarPlugin" .. self:GetTitle() .. "Frame"
796 local frame = _G[name]
797 if not frame or not _G[self.frame:GetName() .. "Text"] or not _G[self.frame:GetName() .. "Icon"] then
798 frame = self:CreateBasicPluginFrame(name)
799  
800 local icon = frame:CreateTexture(name .. "Icon", "ARTWORK")
801 icon:SetWidth(16)
802 icon:SetHeight(16)
803 icon:SetPoint("LEFT", frame, "LEFT")
804  
805 local text = frame:CreateFontString(name .. "Text", "ARTWORK")
806 text:SetWidth(134)
807 text:SetHeight(24)
808 text:SetPoint("LEFT", icon, "RIGHT", 0, 1)
809 text:SetFontObject(GameFontNormal)
810 end
811 self.frame = frame
812 self.textFrame = _G[self.frame:GetName() .. "Text"]
813 self.iconFrame = _G[self.frame:GetName() .. "Icon"]
814 else
815 self.userDefinedFrame = true
816 end
817  
818 self.frame.plugin = self
819 self.frame:SetParent(UIParent)
820 self.frame:SetPoint("RIGHT", UIParent, "LEFT", -5, 0)
821 self.frame:Hide()
822  
823 if self.hasIcon then
824 self:SetIcon(self.hasIcon)
825 end
826  
827 if CheckFuBar() then
828 FuBar:RegisterPlugin(self)
829 end
830 end
831  
832 local CheckShow = function(self, panelId)
833 if not self.frame:IsShown() and (not self.minimapFrame or not self.minimapFrame:IsShown()) then
834 self:Show(panelId)
835 Dewdrop:Refresh(2)
836 end
837 end
838  
839 local recheckPlugins
840 function FuBarPlugin.OnEmbedEnable(FuBarPlugin, self)
841 if self:IsIconShown() then
842 self.iconFrame:Show()
843 else
844 self.iconFrame:Hide()
845 end
846 self:CheckWidth(true)
847  
848 if not self.hideWithoutStandby or not self.db.profile.hidden then
849 if FuBarPlugin.enabledPlugins[self] then
850 CheckShow(self, self.panelIdTmp)
851 else
852 FuBarPlugin:ScheduleEvent(CheckShow, 0, self, self.panelIdTmp)
853 end
854 end
855 FuBarPlugin.enabledPlugins[self] = true
856  
857 if not self.overrideTooltip and not self.cannotDetachTooltip and self.db and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then
858 FuBarPlugin:ScheduleEvent(self.DetachTooltip, 0, self)
859 end
860  
861 if self:IsLoadOnDemand() and CheckFuBar() then
862 if not FuBar.db.profile.loadOnDemand then
863 FuBar.db.profile.loadOnDemand = {}
864 end
865 if not FuBar.db.profile.loadOnDemand[self.folderName] then
866 FuBar.db.profile.loadOnDemand[self.folderName] = {}
867 end
868 FuBar.db.profile.loadOnDemand[self.folderName].disabled = nil
869 end
870  
871 if CheckFuBar() and AceLibrary:HasInstance("AceConsole-2.0") then
872 if not recheckPlugins then
873 local AceConsole = AceLibrary("AceConsole-2.0")
874 local AceOO = AceLibrary("AceOO-2.0")
875 function recheckPlugins()
876 for k,v in pairs(AceConsole.registry) do
877 if type(v) == "table" and v.args and AceOO.inherits(v.handler, FuBarPlugin) and not v.independentProfile then
878 v.args.profile = nil
879 end
880 end
881 end
882 end
883 FuBarPlugin:ScheduleEvent(recheckPlugins, 0)
884 end
885 end
886  
887 function FuBarPlugin.OnEmbedDisable(FuBarPlugin, self)
888 self:Hide()
889  
890 if self:IsLoadOnDemand() and CheckFuBar() then
891 if not FuBar.db.profile.loadOnDemand then
892 FuBar.db.profile.loadOnDemand = {}
893 end
894 if not FuBar.db.profile.loadOnDemand[self.folderName] then
895 FuBar.db.profile.loadOnDemand[self.folderName] = {}
896 end
897 FuBar.db.profile.loadOnDemand[self.folderName].disabled = true
898 end
899 end
900  
901 function FuBarPlugin.OnEmbedProfileEnable(FuBarPlugin, self)
902 self:Update()
903 if self.db and self.db.profile then
904 if not self.db.profile.detachedTooltip then
905 self.db.profile.detachedTooltip = {}
906 end
907 if Tablet.registry[self.frame] then
908 Tablet:UpdateDetachedData(self.frame, self.db.profile.detachedTooltip)
909 else
910 FuBarPlugin.RegisterTablet(self)
911 end
912 end
913 end
914  
915 function FuBarPlugin.GetAceOptionsDataTable(FuBarPlugin, self)
916 return {
917 icon = {
918 type = "toggle",
919 name = "Show icon",
920 desc = "Show icon",
921 set = "ToggleIconShown",
922 get = "IsIconShown",
923 hidden = function()
924 return not self.hasIcon or self.hasNoText or self:IsMinimapAttached() or not self.db
925 end,
926 order = -13.7,
927 handler = self,
928 },
929 text = {
930 type = "toggle",
931 name = "Show text",
932 desc = "Show text",
933 set = "ToggleTextShown",
934 get = "IsTextShown",
935 hidden = function()
936 return self.cannotHideText or not self.hasIcon or self.hasNoText or self:IsMinimapAttached() or not self.db
937 end,
938 order = -13.6,
939 handler = self,
940 },
941 colorText = {
942 type = "toggle",
943 name = "Show colored text",
944 desc = "Show colored text",
945 set = "ToggleTextColored",
946 get = "IsTextColored",
947 hidden = function()
948 return self.userDefinedFrame or self.hasNoText or self.hasNoColor or self:IsMinimapAttached() or not self.db
949 end,
950 order = -13.5,
951 handler = self,
952 },
953 detachTooltip = {
954 type = "toggle",
955 name = "Detach tooltip",
956 desc = "Detach tooltip",
957 get = "IsTooltipDetached",
958 set = "ToggleTooltipDetached",
959 hidden = function()
960 return self.overrideTooltip or self.cannotDetachTooltip
961 end,
962 order = -13.4,
963 handler = self,
964 },
965 lockTooltip = {
966 type = "toggle",
967 name = "Lock tooltip",
968 desc = "Lock tooltip",
969 get = function()
970 return Tablet:IsLocked(self.frame)
971 end,
972 set = function()
973 return Tablet:ToggleLocked(self.frame)
974 end,
975 disabled = function()
976 return not self:IsTooltipDetached()
977 end,
978 hidden = function()
979 return self.overrideTooltip or self.cannotDetachTooltip
980 end,
981 order = -13.3,
982 handler = self,
983 },
984 position = {
985 type = "text",
986 name = "Position",
987 desc = "Position",
988 validate = {
989 LEFT = "Left",
990 CENTER = "Center",
991 RIGHT = "Right"
992 },
993 get = function()
994 return self.panel:GetPluginSide(self)
995 end,
996 set = function(value)
997 self.panel:SetPluginSide(self, value)
998 end,
999 hidden = function()
1000 return self:IsMinimapAttached() or self:IsDisabled() or not self.panel
1001 end,
1002 order = -13.2,
1003 handler = self,
1004 },
1005 minimapAttach = {
1006 type = "toggle",
1007 name = "Attach to minimap",
1008 desc = "Attach to minimap",
1009 get = "IsMinimapAttached",
1010 set = "ToggleMinimapAttached",
1011 hidden = function()
1012 return (self.cannotAttachToMinimap and not self:IsMinimapAttached()) or not CheckFuBar() or self:IsDisabled()
1013 end,
1014 order = -13.1,
1015 handler = self,
1016 },
1017 hide = {
1018 type = "toggle",
1019 cmdName = "Hidden",
1020 guiName = "Hide FuBar plugin",
1021 desc = "Hide FuBar plugin",
1022 get = function()
1023 return not self.frame:IsShown() and (not self.minimapFrame or not self.minimapFrame:IsShown())
1024 end,
1025 set = function()
1026 if not self.frame:IsShown() and (not self.minimapFrame or not self.minimapFrame:IsShown()) then
1027 self:Show()
1028 else
1029 self:Hide()
1030 end
1031 end,
1032 hidden = function()
1033 return not self.hideWithoutStandby or self:IsDisabled()
1034 end,
1035 order = -13,
1036 handler = self,
1037 },
1038 }
1039 end
1040  
1041 local function activate(self, oldLib, oldDeactivate)
1042 FuBarPlugin = self
1043  
1044 if oldLib then
1045 self.registry = oldLib.registry
1046 self.folderNames = oldLib.folderNames
1047 self.enabledPlugins = oldLib.enabledPlugins
1048 end
1049  
1050 if not self.registry then
1051 self.registry = {}
1052 end
1053 if not self.folderNames then
1054 self.folderNames = {}
1055 end
1056 if not self.enabledPlugins then
1057 self.enabledPlugins = {}
1058 end
1059  
1060 FuBarPlugin.activate(self, oldLib, oldDeactivate)
1061  
1062 if oldDeactivate then
1063 oldDeactivate(oldLib)
1064 end
1065 end
1066  
1067 local function external(self, major, instance)
1068 if major == "AceEvent-2.0" then
1069 AceEvent = instance
1070  
1071 AceEvent:embed(self)
1072 elseif major == "Tablet-2.0" then
1073 Tablet = instance
1074 elseif major == "Dewdrop-2.0" then
1075 Dewdrop = instance
1076 end
1077 end
1078  
1079 AceLibrary:Register(FuBarPlugin, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
1080  
1081 local MinimapContainer = {}
1082  
1083 local IsMinimapSquare
1084 do
1085 local value
1086 function IsMinimapSquare()
1087 if value == nil then
1088 if not AceEvent or not AceEvent:IsFullyInitialized() then
1089 return IsAddOnLoaded("CornerMinimap") or IsAddOnLoaded("SquareMinimap") or IsAddOnLoaded("Squeenix")
1090 else
1091 value = IsAddOnLoaded("CornerMinimap") or IsAddOnLoaded("SquareMinimap") or IsAddOnLoaded("Squeenix") and true or false
1092 end
1093 end
1094 return value
1095 end
1096 end
1097  
1098 function MinimapContainer:AddPlugin(plugin)
1099 if CheckFuBar() and FuBar:IsChangingProfile() then
1100 return
1101 end
1102 if plugin.panel ~= nil then
1103 plugin.panel:RemovePlugin(plugin)
1104 end
1105 plugin.panel = self
1106 if not plugin.minimapFrame then
1107 local frame = CreateFrame("Button", plugin.frame:GetName() .. "MinimapButton", Minimap)
1108 plugin.minimapFrame = frame
1109 AceLibrary(MAJOR_VERSION).RegisterTablet(plugin)
1110 Tablet:Register(frame, plugin.frame)
1111 frame.plugin = plugin
1112 frame:SetWidth(31)
1113 frame:SetHeight(31)
1114 frame:SetFrameStrata("BACKGROUND")
1115 frame:SetFrameLevel(4)
1116 frame:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight")
1117 local icon = frame:CreateTexture(frame:GetName() .. "Icon", "BACKGROUND")
1118 plugin.minimapIcon = icon
1119 local path = plugin:GetIcon() or (plugin.iconFrame and plugin.iconFrame:GetTexture()) or "Interface\\Icons\\INV_Misc_QuestionMark"
1120 icon:SetTexture(path)
1121 if string.sub(path, 1, 16) == "Interface\\Icons\\" then
1122 icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
1123 else
1124 icon:SetTexCoord(0, 1, 0, 1)
1125 end
1126 icon:SetWidth(20)
1127 icon:SetHeight(20)
1128 icon:SetPoint("TOPLEFT", frame, "TOPLEFT", 7, -5)
1129 local overlay = frame:CreateTexture(frame:GetName() .. "Overlay","OVERLAY")
1130 overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder")
1131 overlay:SetWidth(53)
1132 overlay:SetHeight(53)
1133 overlay:SetPoint("TOPLEFT",frame,"TOPLEFT")
1134 frame:EnableMouse(true)
1135 frame:RegisterForClicks("LeftButtonUp")
1136 frame.plugin = plugin
1137 frame:SetScript("OnClick", function()
1138 if type(plugin.OnClick) == "function" then
1139 if not this.dragged then
1140 plugin:OnClick(arg1)
1141 end
1142 end
1143 end)
1144 frame:SetScript("OnDoubleClick", function()
1145 if type(plugin.OnDoubleClick) == "function" then
1146 plugin:OnDoubleClick(arg1)
1147 end
1148 end)
1149 frame:SetScript("OnReceiveDrag", function()
1150 if type(plugin.OnReceiveDrag) == "function" then
1151 if not this.dragged then
1152 plugin:OnReceiveDrag()
1153 end
1154 end
1155 end)
1156 frame:SetScript("OnMouseDown", function()
1157 this.dragged = false
1158 if arg1 == "LeftButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
1159 HideDropDownMenu(1)
1160 if type(plugin.OnMouseDown) == "function" then
1161 plugin:OnMouseDown(arg1)
1162 end
1163 elseif arg1 == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
1164 plugin:OpenMenu(frame)
1165 else
1166 HideDropDownMenu(1)
1167 if type(plugin.OnMouseDown) == "function" then
1168 plugin:OnMouseDown(arg1)
1169 end
1170 end
1171 if plugin.OnClick or plugin.OnMouseDown or plugin.OnMouseUp or plugin.OnDoubleClick then
1172 if string.sub(this.plugin.minimapIcon:GetTexture(), 1, 16) == "Interface\\Icons\\" then
1173 plugin.minimapIcon:SetTexCoord(0.14, 0.86, 0.14, 0.86)
1174 else
1175 plugin.minimapIcon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
1176 end
1177 end
1178 end)
1179 frame:SetScript("OnMouseUp", function()
1180 if not this.dragged and type(plugin.OnMouseUp) == "function" then
1181 plugin:OnMouseUp(arg1)
1182 end
1183 if string.sub(this.plugin.minimapIcon:GetTexture(), 1, 16) == "Interface\\Icons\\" then
1184 plugin.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
1185 else
1186 plugin.minimapIcon:SetTexCoord(0, 1, 0, 1)
1187 end
1188 end)
1189 frame:RegisterForDrag("LeftButton")
1190 frame:SetScript("OnDragStart", self.OnDragStart)
1191 frame:SetScript("OnDragStop", self.OnDragStop)
1192 end
1193 plugin.frame:Hide()
1194 plugin.minimapFrame:Show()
1195 self:ReadjustLocation(plugin)
1196 table.insert(self.plugins, plugin)
1197 local exists = false
1198 return true
1199 end
1200  
1201 function MinimapContainer:RemovePlugin(index)
1202 if CheckFuBar() and FuBar:IsChangingProfile() then
1203 return
1204 end
1205 if type(index) == "table" then
1206 index = self:IndexOfPlugin(index)
1207 if not index then
1208 return
1209 end
1210 end
1211 local t = self.plugins
1212 local plugin = t[index]
1213 assert(plugin.panel == self, "Plugin has improper panel field")
1214 plugin:SetPanel(nil)
1215 table.remove(t, index)
1216 return true
1217 end
1218  
1219 function MinimapContainer:ReadjustLocation(plugin)
1220 local frame = plugin.minimapFrame
1221 if plugin.db and plugin.db.profile.minimapPositionWild then
1222 frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.db.profile.minimapPositionX, plugin.db.profile.minimapPositionY)
1223 elseif not plugin.db and plugin.minimapPositionWild then
1224 frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.minimapPositionX, plugin.minimapPositionY)
1225 else
1226 local position
1227 if plugin.db then
1228 position = plugin.db.profile.minimapPosition or plugin.defaultMinimapPosition or math.random(1, 360)
1229 else
1230 position = plugin.minimapPosition or plugin.defaultMinimapPosition or math.random(1, 360)
1231 end
1232 local angle = math.rad(position or 0)
1233 local x,y
1234 if not IsMinimapSquare() then
1235 x = math.cos(angle) * 80
1236 y = math.sin(angle) * 80
1237 else
1238 x = 110 * math.cos(angle)
1239 y = 110 * math.sin(angle)
1240 x = math.max(-82, math.min(x, 84))
1241 y = math.max(-86, math.min(y, 82))
1242 end
1243 frame:SetPoint("CENTER", Minimap, "CENTER", x, y)
1244 end
1245 end
1246  
1247 function MinimapContainer:GetPlugin(index)
1248 return self.plugins[index]
1249 end
1250  
1251 function MinimapContainer:GetNumPlugins()
1252 return table.getn(self.plugins)
1253 end
1254  
1255 function MinimapContainer:IndexOfPlugin(plugin)
1256 for i,p in ipairs(self.plugins) do
1257 if p == plugin then
1258 return i, "MINIMAP"
1259 end
1260 end
1261 end
1262  
1263 function MinimapContainer:HasPlugin(plugin)
1264 return self:IndexOfPlugin(plugin) ~= nil
1265 end
1266  
1267 function MinimapContainer:GetPluginSide(plugin)
1268 local index = self:IndexOfPlugin(plugin)
1269 assert(index, "Plugin not in panel")
1270 return "MINIMAP"
1271 end
1272  
1273 function MinimapContainer.OnDragStart()
1274 this.dragged = true
1275 this:LockHighlight()
1276 this:SetScript("OnUpdate", MinimapContainer.OnUpdate)
1277 if string.sub(this.plugin.minimapIcon:GetTexture(), 1, 16) == "Interface\\Icons\\" then
1278 this.plugin.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
1279 else
1280 this.plugin.minimapIcon:SetTexCoord(0, 1, 0, 1)
1281 end
1282 end
1283  
1284 function MinimapContainer.OnDragStop()
1285 this:SetScript("OnUpdate", nil)
1286 this:UnlockHighlight()
1287 end
1288  
1289 function MinimapContainer.OnUpdate()
1290 if not IsAltKeyDown() then
1291 local mx, my = Minimap:GetCenter()
1292 local px, py = GetCursorPosition()
1293 local scale = UIParent:GetEffectiveScale()
1294 px, py = px / scale, py / scale
1295 local position = math.deg(math.atan2(py - my, px - mx))
1296 if position <= 0 then
1297 position = position + 360
1298 elseif position > 360 then
1299 position = position - 360
1300 end
1301 if this.plugin.db then
1302 this.plugin.db.profile.minimapPosition = position
1303 this.plugin.db.profile.minimapPositionX = nil
1304 this.plugin.db.profile.minimapPositionY = nil
1305 this.plugin.db.profile.minimapPositionWild = nil
1306 else
1307 this.plugin.minimapPosition = position
1308 this.plugin.minimapPositionX = nil
1309 this.plugin.minimapPositionY = nil
1310 this.plugin.minimapPositionWild = nil
1311 end
1312 else
1313 local px, py = GetCursorPosition()
1314 local scale = UIParent:GetEffectiveScale()
1315 px, py = px / scale, py / scale
1316 if this.plugin.db then
1317 this.plugin.db.profile.minimapPositionX = px
1318 this.plugin.db.profile.minimapPositionY = py
1319 this.plugin.db.profile.minimapPosition = nil
1320 this.plugin.db.profile.minimapPositionWild = true
1321 else
1322 this.plugin.minimapPositionX = px
1323 this.plugin.minimapPositionY = py
1324 this.plugin.minimapPosition = nil
1325 this.plugin.minimapPositionWild = true
1326 end
1327 end
1328 MinimapContainer:ReadjustLocation(this.plugin)
1329 end
1330  
1331 local function activate(self, oldLib, oldDeactivate)
1332 MinimapContainer = self
1333  
1334 if oldLib then
1335 self.plugins = oldLib.plugins
1336 end
1337  
1338 if not self.plugins then
1339 self.plugins = {}
1340 end
1341  
1342 if oldDeactivate then
1343 oldDeactivate(oldLib)
1344 end
1345 end
1346  
1347 AceLibrary:Register(MinimapContainer, MINIMAPCONTAINER_MAJOR_VERSION, MINOR_VERSION, activate)