vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1  
2  
3 DetachedMiniButtonsData = {};
4  
5 local FullSizeButtons =
6 {
7 ["MiniMapTrackingFrame"] = true,
8 };
9  
10 local DefaultButtons = {
11 ["MinimapZoomIn"] = "MinimapZoomIn",
12 ["MinimapZoomOut"] = "MinimapZoomOut",
13 }
14  
15 local SpecialButtons = {
16 ["WIM_IconFrameButton"] = "WIM_IconFrameButton",
17 ["MiniMapBattlefieldFrame"] = "MiniMapBattlefieldFrame",
18 ["GameTimeFrame"] = "GameTimeFrame",
19 ["GroupCalendarButton"] = "GroupCalendarButton",
20 ["Gypsy_Button"] = "Gypsy_Button",
21 ["WaterboyIcon"] = "WaterboyIcon",
22 ["UberHealOnClick_Minimap"] = "UberHealOnClick_Minimap",
23 ["GuildAdsMinimapButton"] = "GuildAdsMinimapButton",
24 ["Slib_MinimapBtn"] = "Slib_MinimapBtn",
25 ["Nurfed_LockButton"] = "Nurfed_LockButton",
26 ["RecipeRadarMinimapButtonHighlightFrame"] = "RecipeRadarMinimapButtonHighlightFrame",
27 }
28  
29 local _MASKS_ =
30 {
31 --["AtlasButton"] = "AtlasButtonFrame",
32 --["CensusButton"] = "CensusButtonFrame",
33 --["CT_RASets_Button"] = "CT_RASetsFrame",
34 --["TheYatlasButton"] = "YatlasButtonFrame",
35 ["AM_MinimapButton"] = "AM_MinimapFrame",
36 ["CT_OptionBarFrame"] = "CT_OptionButton",
37 ["FishingBuddyMinimapFrame"] = "FishingBuddyMinimapButton",
38 --["AtlasButtonFrame"] = "AtlasButton",
39 ["RecipeRadarMinimapButtonFrame"] = "RecipeRadarMinimapButton",
40 ["AccountantButtonFrame"] = "AccountantButton",
41 ["OpiumButtonFrame"] = "OpiumButton",
42 ["Perl_Config_ButtonFrame"] = "PerlButton",
43 --["SW_IconFrame"] = "SW_IconFrame_Button",
44 --["CensusButtonFrame"] = "CensusButton",
45 ["CT_RASetsFrame"] = "CT_RASets_Button",
46 ["RaidRollButtonFrame"] = "RaidRollButtonFrameButton",
47 ["PanzaButtonFrame" ] = "PanzaButton",
48 ["YatlasButtonFrame"] = "TheYatlasButton",
49 ["LazyScriptMinimapFrame"] = "LazyScriptMinimapButton",
50 ["CritLineFrameMini"] = "CritLineButton",
51 ["CleanMinimapButtonFrame"] = "CleanMinimapButton",
52 ["MM_ButtonFrame"] = "MM_Button",
53 ["Wardrobe_IconFrame"] = "Wardrobe_IconFrame",
54 ["HAMinimapFrame"] = "HAMinimapButton",
55 ["kkbk_miniMap"] = "kkbk_miniMapButton1",
56 ["MusicPlayer_ButtonFrame"] = "MusicPlayer_Button",
57 --["CECBMiniMapButtonFrame"] = "CECBMiniMapButton",
58 };
59  
60 local _CLASS_ = "DetachedMiniButtons ";
61 local _VERSION_ = "0.9.22";
62 local _nodock = false;
63 local _lock = false;
64 local _initialized = false;
65 local _player = "";
66 local _realm = "";
67 local _frameList = {};
68 local _INITIALX_ = "INITIALX";
69 local _INITIALY_ = "INITIALY";
70 local _LASTX_ = "LASTX";
71 local _LASTY_ = "LASTY";
72 local _NAME_ = "NAME";
73 local _NODOCK_ = "NODOCK";
74 local _LOCK_ = "LOCK";
75 local _PARENT_ = "PARENT";
76 local _USED_ = "USED";
77 local _MASKED_ = {};
78 local _UIMAXX_ = 0;
79 local _UIMAXY_ = 0;
80  
81 local _oldFishBuddyEnter;
82  
83 _rescanned = false;
84 _starttime = 0;
85  
86 local _DEBUG_ = false;
87  
88  
89 function DEBUG(s)
90 if (_DEBUG_) then
91 DEFAULT_CHAT_FRAME:AddMessage(_CLASS_ .. ":" .. s)
92 end
93 end
94  
95  
96 -- --------------------------------------------------------------------
97 function DetachedMiniButtons_OnLoad()
98  
99 SLASH_DetachedMiniButtons1 = "/dmbs";
100  
101 SlashCmdList["DetachedMiniButtons"] = function (msg)
102 DetachedMiniButtons_Slash(msg);
103 end
104 this:RegisterEvent("PLAYER_ENTERING_WORLD");
105 _starttime = GetTime();
106 end
107  
108 function DetachedMiniButtons_showHelp()
109 DEFAULT_CHAT_FRAME:AddMessage(_CLASS_ .. " " .. _VERSION_);
110 DEFAULT_CHAT_FRAME:AddMessage(SLASH_DetachedMiniButtons1 .. " or " .. SLASH_DetachedMiniButtons1 .. " help : these messages.");
111 DEFAULT_CHAT_FRAME:AddMessage(SLASH_DetachedMiniButtons1 .. " reset : set buttons back to initial positions.");
112 DEFAULT_CHAT_FRAME:AddMessage(SLASH_DetachedMiniButtons1 .. " cfg : show current settings.");
113 DEFAULT_CHAT_FRAME:AddMessage(SLASH_DetachedMiniButtons1 .. " scan : rescan for minimap buttons.");
114 DEFAULT_CHAT_FRAME:AddMessage(SLASH_DetachedMiniButtons1 .. " nodock : do not try to dock buttons near minimap.");
115 DEFAULT_CHAT_FRAME:AddMessage(SLASH_DetachedMiniButtons1 .. " dock : try to dock buttons near minimap.");
116 DEFAULT_CHAT_FRAME:AddMessage(SLASH_DetachedMiniButtons1 .. " lock : lock buttons in place.");
117 DEFAULT_CHAT_FRAME:AddMessage(SLASH_DetachedMiniButtons1 .. " unlock : unlock the buttons.");
118 end
119  
120 function DetachedMiniButtons_showSet()
121 local onoff = "off";
122 if (DetachedMiniButtonsData[_realm][_player][_LOCK_]) then
123 onoff = "on";
124 end;
125 DEFAULT_CHAT_FRAME:AddMessage(_CLASS_ .. " locked buttons: " .. onoff);
126 onoff = "off";
127 if (DetachedMiniButtonsData[_realm][_player][_NODOCK_]) then
128 onoff = "on";
129 end;
130 DEFAULT_CHAT_FRAME:AddMessage(_CLASS_ .. " attempt minimap docking: " .. onoff);
131  
132 end
133 function DetachedMiniButtons_Slash(msg)
134  
135 if (not msg) then
136 DetachedMiniButtons_showHelp();
137 return;
138 end;
139 if (msg == "") then
140 DetachedMiniButtons_showHelp();
141 return;
142 end;
143 if (msg == "help") then
144 DetachedMiniButtons_showHelp();
145 return;
146 end;
147 if (msg == "cfg") then
148 DetachedMiniButtons_showSet();
149 end;
150 if (msg == "scan") then
151 DetachedMiniButtons_GetChildren(msg);
152 return;
153 end;
154 if (msg == "nodock") then
155 DEFAULT_CHAT_FRAME:AddMessage(_CLASS_ .."-This function is currently disabled");
156 DetachedMiniButtonsData[_realm][_player][_NODOCK_] = true;
157 end;
158 if (msg == "dock") then
159 DEFAULT_CHAT_FRAME:AddMessage(_CLASS_ .."-This function is currently disabled");
160 DetachedMiniButtonsData[_realm][_player][_NODOCK_] = false;
161 end;
162 if (msg == "reset") then
163 DetachedMiniButtons_reset(_frameList);
164 end;
165 if (msg == "lock") then
166 DEFAULT_CHAT_FRAME:AddMessage(_CLASS_ .."-Buttons are now locked");
167 DetachedMiniButtonsData[_realm][_player][_LOCK_] = true;
168 end;
169 if (msg == "unlock") then
170 DEFAULT_CHAT_FRAME:AddMessage(_CLASS_ .."-Buttons are now unlocked");
171 DetachedMiniButtonsData[_realm][_player][_LOCK_] = false;
172 end;
173 end
174  
175 function DetachedMiniButtons_OnEvent(event)
176 if (event == "PLAYER_ENTERING_WORLD") then
177 if (not _initialized) then
178 _UIMAXX_ = INT(UIParent:GetRight() - 16);
179 _UIMAXY_ = INT(UIParent:GetTop());
180  
181 _realm = GetRealmName(); -- get our realm
182 _player = UnitName("player") -- get our player name
183  
184 if (not DetachedMiniButtonsData) then
185 DetachedMiniButtonsData = {};
186 end;
187 if (not DetachedMiniButtonsData[_realm]) then
188 DetachedMiniButtonsData[_realm] = {};
189 end
190 if (not DetachedMiniButtonsData[_realm][_player]) then
191 DetachedMiniButtonsData[_realm][_player] = {};
192 end
193 if (not DetachedMiniButtonsData[_realm][_player][_NODOCK_]) then
194 DetachedMiniButtonsData[_realm][_player][_NODOCK_] = _nodock;
195 end;
196 if (not DetachedMiniButtonsData[_realm][_player][_LOCK_]) then
197 DetachedMiniButtonsData[_realm][_player][_LOCK_] = _lock;
198 end;
199  
200 if (FishingBuddy) then
201 if (FishingBuddy.Minimap.Button_OnEnter) then
202 _oldFishBuddyEnter = FishingBuddy.Minimap.Button_OnEnter;
203 FishingBuddy.Minimap.Button_OnEnter=newFishBuddyEnter_OnEnter;
204 else
205 _oldFishBuddyEnter = nil;
206 end;
207 end;
208  
209 _initialized = true;
210 DEFAULT_CHAT_FRAME:AddMessage(_CLASS_ .." " .. _VERSION_ .. " loaded.");
211 end;
212 end
213 end;
214  
215 function newFishBuddyEnter_OnEnter()
216 if ( GameTooltip.fbmmbfinished ) then
217 return;
218 end
219 if ( FishingBuddy.GetSetting("UseButtonHole") == 0 ) then
220 GameTooltip.fbmmbfinished = 1;
221 GameTooltip:SetOwner(FishingBuddyMinimapButton, "ANCHOR_LEFT");
222 GameTooltip:AddLine(FishingBuddy.NAME);
223 local text = FishingBuddy.TooltipBody("MinimapClickToSwitch");
224 GameTooltip:AddLine(text,.8,.8,.8,1);
225 GameTooltip:Show();
226 end
227 end
228  
229 function DetachedMiniButtons_cleanUp()
230 local frame = Sea.util.getValue("RecipeRadarMinimapButtonHighlightFrame");
231 if (frame) then
232 local c = Sea.util.getValue("RecipeRadarMinimapButton");
233 if (c) then
234 frame:SetParent(c);
235 end;
236 end;
237 frame = Sea.util.getValue("RogueTrackerPoisonButton");
238 if (frame) then
239 local c = Sea.util.getValue("RogueTrackerPoisonText");
240 if (c) then
241 c:SetParent(frame);
242 end;
243 end;
244 frame = Sea.util.getValue("RogueTrackerBlindButton");
245 if (frame) then
246 local c = Sea.util.getValue("RogueTrackerBlindText");
247 if (c) then
248 c:SetParent(frame);
249 end;
250 end;
251 frame = Sea.util.getValue("RogueTrackerVanishButton");
252 if (frame) then
253 local c = Sea.util.getValue("RogueTrackerVanishText");
254 if (c) then
255 c:SetParent(frame);
256 end;
257 end;
258 frame = Sea.util.getValue("RogueTrackerFlashButton");
259 if (frame) then
260 local c = Sea.util.getValue("RogueTrackerFlashText");
261 if (c) then
262 c:SetParent(frame);
263 end;
264 end;
265 frame = Sea.util.getValue("RogueTrackerTeaButton");
266 if (frame) then
267 local c = Sea.util.getValue("RogueTrackerTeaText");
268 if (c) then
269 c:SetParent(frame);
270 end;
271 end;
272  
273 if (SquareMinimap) then
274 local nl = {};
275 nl["MiniMapTrackingFrame"] = "MiniMapTrackingFrame";
276 MiniMapTrackingFrame:SetScale(1)
277 DetachedMiniButtons_resolveInitialValues(nl);
278 DetachedMiniButtons_setMovable(nl);
279 DetachedMiniButtons_setInitialRange(nl);
280 DetachedMiniButtons_rePosition(nl);
281 end
282  
283  
284 end;
285  
286 function DetachedMiniButtons_DoInit()
287 local list = {};
288 list = DetachedMiniButtons_AddDefaults(list);
289 list = DetachedMiniButtons_findFrames(list);
290 DetachedMiniButtons_resolveInitialValues(list);
291 DetachedMiniButtons_setMovable(list);
292 DetachedMiniButtons_setInitialRange(list);
293 DetachedMiniButtons_rePosition(list);
294 DetachedMiniButtons_cleanUp();
295 end
296 -- -------------------------------------------------------------------
297 -- -------------------------------------------------------------------
298 -- HELPER FUNCTIONS
299 -- -------------------------------------------------------------------
300 function INT(x)
301 if (x == nil) then
302 return(nil)
303 end
304 return(math.floor(x + 0.5));
305 end
306  
307 function INRANGEX(x)
308 --DEBUG(_UIMAXX_)
309 if (x == nil) then
310 return(true);
311 end;
312 if (x < 0) or (x > _UIMAXX_) then
313 return(false);
314 end;
315 return(true);
316 end
317  
318 function INRANGEY(y)
319 --DEBUG(_UIMAXY_)
320 if (y == nil) then
321 return(true);
322 end;
323 if (y < 0) or (y > _UIMAXY_) then
324 return(false);
325 end;
326 return(true);
327 end
328  
329 function INRANGEXY(x,y)
330 if (x == nil) or (y == nil) then
331 return(true);
332 end;
333 if (x < 0) or (x > _UIMAXX_) or (y < 0) or (y > _UIMAXY_) then
334 return(false);
335 end;
336  
337 return(true);
338 end
339  
340 function INRANGEFRAME(frame)
341 if (frame) then
342 if (frame.GetLeft and frame.GetTop) then
343 local left = INT(frame:GetLeft());
344 local top = INT(frame:GetTop());
345 if (left ~= nil) and (top ~= nil) then
346 if (left < -8) or (left > _UIMAXX_ - 8) or (top < -8) or (top > _UIMAXY_ - 8) then
347 --DEBUG("NOT IN RANGE:" .. frame:GetName());
348 return(false);
349 end
350 end;
351 end
352 end;
353 return(true);
354 end
355  
356 function RANGEX(x)
357 if (x == nil) then
358 return(nil)
359 end;
360 if (x < -8) then
361 return(x);
362 end;
363 if (x > _UIMAXX_) then
364 return(_UIMAXX_ - 2);
365 end;
366 return(x);
367 end
368  
369 function RANGEY(x)
370 if (x == nil) then
371 return(nil)
372 end;
373 if (x < -8) then
374 return(x);
375 end;
376 if (x > _UIMAXY_ ) then
377 return(_UIMAXY_);
378 end;
379 return(x);
380 end
381  
382 -- --------------------------------------------------------------------
383 --
384 -- --------------------------------------------------------------------
385 function isExclude(s)
386 if (string.find(s,"GatherNote") ~= nil) then
387 return(true);
388 end;
389 if (string.find(s,"PoisonPouch") ~= nil) then
390 return(true);
391 end;
392 if (string.find(s,"IFrameManagerButton") ~= nil) then
393 return(true);
394 end;
395 --if (string.find(s,"MiniMapTrackingFrame") ~= nil) then
396 -- return(true);
397 --end;
398 if (string.find(s,"MM_CoreFrame") ~= nil) then
399 return(true);
400 end;
401 if (string.find(s,"MiniMapBattlefieldDropDown") ~= nil) then
402 return(true);
403 end;
404 if (string.find(s,"simpleMinimapFrame") ~= nil) then
405 return(true);
406 end;
407 --if (string.find(s,"FuBarPlugin") ~= nil) then
408 -- return(true);
409 --end;
410 if (string.find(s,"Sprocket") ~= nil) then
411 return(true);
412 end;
413 if (string.find(s,"RogueTracker") ~= nil) and (string.find(s,"DraggingFrame") ~= nil) then
414 return(true);
415 end;
416 return(false);
417 end
418  
419 function isInclude(s)
420 if (string.find(s,"SbQuestIcon") ~= nil) then
421 return(true);
422 end
423 if (string.find(s,"WIM") ~= nil) then
424 return(true);
425 end
426 if (string.find(s,"UI") ~= nil) then
427 return(true);
428 end
429 if (string.find(s,"Frame") ~= nil) then
430 return(true);
431 end
432 if (string.find(s,"Button") ~= nil) then
433 return(true);
434 end
435 if (string.find(s,"CT_") ~= nil) then
436 return(true);
437 end;
438 if (string.find(s,"CTA_MinimapIcon") ~= nil) then
439 return(true);
440 end;
441 if (string.find(s,"MetaMap") ~= nil) then
442 return(true);
443 end;
444 if (string.find(s,"HunterVSNefarianIcon") ~= nil) then
445 return(true);
446 end;
447 if (string.find(s,"mgames_minimap") ~= nil) then
448 return(true);
449 end;
450 if (string.find(s,"kkbk_") ~= nil) then
451 return(true);
452 end;
453  
454 return(false);
455 end
456  
457 function DetachedMiniButtons_Mask(n)
458 if (_MASKS_[n]) then
459 _MASKED_[_MASKS_[n]] = n;
460 return(_MASKS_[n]);
461 end;
462 return(n);
463 end
464  
465 function DetachedMiniButtons_ResolveMask(n,frame)
466 if (_MASKS_[n]) then
467 _MASKED_[_MASKS_[n]] = n;
468 return(_MASKS_[n]);
469 end;
470 local children = { frame:GetChildren()};
471 --DEBUG("CHILDREN:" .. n .. table.getn(children));
472 if (table.getn(children) == 1) then
473 --DEBUG("ONE CHILD: " .. n);
474 local child = children[1];
475 _MASKS_[n] = child:GetName();
476 return(child:GetName());
477 end
478  
479 return(n);
480 end
481  
482  
483 function DetachedMiniButtons_AddDefaults(list)
484 for n in DefaultButtons do
485 if (DetachedMiniButtons_AddFrameName(n,n)) then
486 list[n] = n;
487 end
488 end;
489 return(list);
490 end
491  
492 function DetachedMiniButtons_AddFrameName(n,p)
493 local frame = Sea.util.getValue(n);
494 if (frame) then
495 if ((not frame.GetLeft) and (not frame.GetTop)) then
496 return(false);
497 end;
498 if (frame:GetLeft() == nil) then
499 return(false);
500 end;
501 if (frame:GetTop() == nil) then
502 return(false);
503 end;
504  
505 if (not _frameList[n]) then
506 _frameList[n] = n;
507 end;
508 if (not DetachedMiniButtonsData[_realm][_player][n]) then
509 DetachedMiniButtonsData[_realm][_player][n] = {};
510 end
511 if (not DetachedMiniButtonsData[_realm][_player][n][_NAME_]) then
512 DetachedMiniButtonsData[_realm][_player][n][_NAME_] = n;
513 end;
514  
515 if (not DetachedMiniButtonsData[_realm][_player][n][_INITIALX_]) then
516 DetachedMiniButtonsData[_realm][_player][n][_INITIALX_] = INT(frame:GetLeft());
517 end
518 if (not DetachedMiniButtonsData[_realm][_player][n][_INITIALY_]) then
519 DetachedMiniButtonsData[_realm][_player][n][_INITIALY_] = INT(frame:GetTop());
520 end
521 if (not DetachedMiniButtonsData[_realm][_player][n][_PARENT_]) then
522 DetachedMiniButtonsData[_realm][_player][n][_PARENT_] = p;
523 end
524 if (not DetachedMiniButtonsData[_realm][_player][n][_USED_]) then
525 DetachedMiniButtonsData[_realm][_player][n][_USED_] = false;
526 end
527 return(true);
528 end;
529 return(false);
530 end
531  
532 function DetachedMiniButtons_findFrames(list)
533 if (Minimap.GetChildren) then
534 local children = { Minimap:GetChildren()};
535 if (children) then
536 for _, child in children do
537 if (child.GetName and child:GetName()) then
538 local n = child:GetName();
539 local p = n;
540 if isInclude(n) and not isExclude(n) then
541 --DEFAULT_CHAT_FRAME:AddMessage(n);
542 n = DetachedMiniButtons_ResolveMask(n,child);
543 if (DetachedMiniButtons_AddFrameName(n,p)) then
544 list[n] = n;
545 end;
546 end
547 end
548 end
549 end
550 end
551 if (MinimapBackdrop.GetChildren) then
552 local children = { MinimapBackdrop:GetChildren()};
553 if (children) then
554 for _, child in children do
555 if (child.GetName and child:GetName()) then
556 local n = child:GetName();
557 local p = n;
558 if isInclude(n) and not isExclude(n) then
559 --DEFAULT_CHAT_FRAME:AddMessage(n);
560 n = DetachedMiniButtons_ResolveMask(n,child);
561 if (DetachedMiniButtons_AddFrameName(n,p)) then
562 list[n] = n;
563 end;
564 end
565 end
566 end
567 end
568 end
569  
570 for n in SpecialButtons do
571 local s = n;
572 local frame = Sea.util.getValue(s);
573 if (frame) then
574 if (DetachedMiniButtons_AddFrameName(s,s)) then
575 list[s] = s;
576 end;
577 end;
578  
579 end
580  
581 return(list);
582 end;
583  
584 function DetachedMiniButtons_resolveInitialValues(list)
585 for framename in list do
586 if (DetachedMiniButtonsData[_realm][_player][framename][_INITIALX_] and
587 DetachedMiniButtonsData[_realm][_player][framename][_INITIALY_]) then
588  
589 if (not INRANGEX(DetachedMiniButtonsData[_realm][_player][framename][_INITIALX_])) then
590 DetachedMiniButtonsData[_realm][_player][framename][_INITIALX_] =
591 INT(RANGEX(DetachedMiniButtonsData[_realm][_player][framename][_INITIALX_])) - 10;
592 end;
593 if (not INRANGEY(DetachedMiniButtonsData[_realm][_player][framename][_INITIALY_])) then
594 DetachedMiniButtonsData[_realm][_player][framename][_INITIALY_] =
595 INT(RANGEY(DetachedMiniButtonsData[_realm][_player][framename][_INITIALY_])) - 10;
596 end;
597  
598 end
599 end
600 end
601  
602 function DetachedMiniButtons_setInitialRange(list)
603 local frame;
604 for n in list do
605 --DEFAULT_CHAT_FRAME:AddMessage("FRAME: " .. n);
606 if (DetachedMiniButtonsData[_realm][_player][n]) then
607 if (not DetachedMiniButtonsData[_realm][_player][n][_LASTX_] and
608 not DetachedMiniButtonsData[_realm][_player][n][_LASTY_]) then
609 --
610 frame = Sea.util.getValue(n);
611 if (frame) then
612 if (not INRANGEFRAME(frame)) then
613 --DEFAULT_CHAT_FRAME:AddMessage("CUR: " .. curx .. ":" .. frame:GetLeft());
614 frame.currentX = INT(RANGEX(frame:GetLeft())) - 16;
615 frame.currentY = INT(RANGEY(frame:GetTop()));
616 frame:ClearAllPoints();
617 frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT",frame.currentX, frame.currentY);
618 DetachedMiniButtonsData[_realm][_player][n][_INITIALX_] = INT(frame:GetLeft());
619 DetachedMiniButtonsData[_realm][_player][n][_INITIALY_] = INT(frame:GetTop());
620 end;
621 end
622 end;
623 end;
624 end
625 end
626  
627  
628 function DetachedMiniButtons_setMovable(list)
629  
630 for framename in list do
631 local frame = Sea.util.getValue(framename);
632 if (frame) then
633 --DEFAULT_CHAT_FRAME:AddMessage(framename);
634 frame:RegisterForDrag("LeftButton");
635 frame:SetParent(UIParent);
636 frame:SetMovable(1);
637 frame.currentX = RANGEX(INT(frame:GetLeft()));
638 frame.currentY = RANGEY(INT(frame:GetTop()));
639 if (framename == "GameTimeFrame") then
640 frame:SetFrameLevel(0);
641 end;
642 if (framename == "GroupCalendarButton") then
643 frame:SetFrameLevel(1);
644 end;
645 if (framename == "MiniMapTrackingFrame") then
646 frame:SetFrameLevel(2);
647 end;
648  
649 local s = nil;
650  
651 --if (DetachedMiniButtonsData[_realm][_player][framename][_PARENT_]) then
652 -- if (DetachedMiniButtonsData[_realm][_player][framename][_PARENT_] ~= framename) then
653 -- s = DetachedMiniButtonsData[_realm][_player][framename][_PARENT_];
654 -- end;
655 --end;
656  
657 --frame:SetFrameLevel(frame:GetFrameLevel()+1);
658 --if (s ~= nil) then
659 -- local p = Sea.util.getValue(s);
660 -- if (p) then
661 -- p:SetParent(UIParent);
662 -- end;
663 --end;
664  
665 Sea.util.hook( framename, "DetachedMiniButtons_Master_OnDragStart", "replace", "OnDragStart" );
666 Sea.util.hook( framename, "DetachedMiniButtons_Master_OnDragStop", "replace", "OnDragStop" );
667 Sea.util.hook( framename, "DetachedMiniButtons_OnUpdate", "replace", "OnUpdate" );
668  
669 end
670 end
671 end
672  
673  
674 function DetachedMiniButtons_rePosition(list)
675 for framename in list do
676 if (DetachedMiniButtonsData[_realm][_player][framename]) then
677 if (DetachedMiniButtonsData[_realm][_player][framename][_LASTX_] and
678 DetachedMiniButtonsData[_realm][_player][framename][_LASTY_]) then
679  
680 local frame = Sea.util.getValue(framename);
681 if (frame) then
682 frame:ClearAllPoints();
683 frame.currentX = INT(DetachedMiniButtonsData[_realm][_player][framename][_LASTX_]);
684 frame.currentY = INT(DetachedMiniButtonsData[_realm][_player][framename][_LASTY_]);
685 frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT",frame.currentX,frame.currentY);
686 DetachedMiniButtonsData[_realm][_player][framename][_LASTX_] = INT(frame:GetLeft());
687 DetachedMiniButtonsData[_realm][_player][framename][_LASTY_] = INT(frame:GetTop());
688 end;
689 end;
690 end;
691 end;
692 end
693  
694 function DetachedMiniButtons_reset(list)
695 for framename in list do
696 if (DetachedMiniButtonsData[_realm][_player][framename]) then
697 if (DetachedMiniButtonsData[_realm][_player][framename][_INITIALX_] and
698 DetachedMiniButtonsData[_realm][_player][framename][_INITIALY_]) then
699  
700 local frame = Sea.util.getValue(framename);
701 if (frame) then
702 frame:ClearAllPoints();
703 frame.currentX = RANGEX(INT(DetachedMiniButtonsData[_realm][_player][framename][_INITIALX_]));
704 frame.currentY = RANGEY(INT(DetachedMiniButtonsData[_realm][_player][framename][_INITIALY_]));
705 frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT",frame.currentX,frame.currentY);
706 DetachedMiniButtonsData[_realm][_player][framename][_LASTX_] = INT(frame:GetLeft());
707 DetachedMiniButtonsData[_realm][_player][framename][_LASTY_] = INT(frame:GetTop());
708 end;
709 end;
710 end;
711 end;
712  
713 end;
714  
715 function DetachedMiniButtons_GetChildren(msg)
716 local count = 0;
717 local newlist = {};
718 if (msg == nil) then
719 msg = "text";
720 end;
721  
722 if (msg ~= "silent") then
723 DEFAULT_CHAT_FRAME:AddMessage("Searching for new Minimap Buttons");
724 end;
725  
726 if (Minimap.GetChildren) then
727 local children = { Minimap:GetChildren()};
728 if (children) then
729 for _, child in children do
730 if (child.GetName and child:GetName()) then
731 local n = child:GetName();
732 local p = n;
733 if isInclude(n) and not isExclude(n) then
734 n = DetachedMiniButtons_ResolveMask(n,child);
735 if (not _frameList[n]) then
736 count = count + 1;
737 newlist[n] = n;
738 DetachedMiniButtons_AddFrameName(n,p);
739 end
740 end
741 end
742 end
743 end
744 end
745  
746 if (MinimapBackdrop.GetChildren) then
747 local children = { MinimapBackdrop:GetChildren()};
748 if (children) then
749 for _, child in children do
750 if (child.GetName and child:GetName()) then
751 local n = child:GetName();
752 local p = n;
753 if isInclude(n) and not isExclude(n) then
754 n = DetachedMiniButtons_ResolveMask(n,child);
755 if (not _frameList[n]) then
756 count = count + 1;
757 newlist[n] = n;
758 DetachedMiniButtons_AddFrameName(n,p);
759 end
760 end
761 end
762 end
763 end
764 end
765  
766 if (count > 0) then
767 if (msg ~= "silent") then
768 DEFAULT_CHAT_FRAME:AddMessage("Found " .. count .. " new buttons");
769 end
770 DetachedMiniButtons_setInitialRange(newlist);
771 DetachedMiniButtons_setMovable(newlist);
772 DetachedMiniButtons_rePosition(newlist);
773 else
774 if (msg ~= "silent") then
775 DEFAULT_CHAT_FRAME:AddMessage("No new buttons found");
776 end;
777 end
778 end
779  
780 -- ---------------------------------------------------------------------------
781 -- ---------------------------------------------------------------------------
782 function DetachedMiniButtons_Master_OnDragStart()
783 if (DetachedMiniButtonsData[_realm][_player][_LOCK_]) then
784 return;
785 end;
786 this.isMoving = true;
787 this:StartMoving();
788 --DEFAULT_CHAT_FRAME:AddMessage("NAME:" .. this:GetName());
789 end
790  
791 function DetachedMiniButtons_Master_OnDragStop()
792 this.isMoving = false;
793 this:StopMovingOrSizing();
794 local n = this:GetName();
795 DetachedMiniButtonsData[_realm][_player][n][_LASTX_] = INT(this:GetLeft());
796 DetachedMiniButtonsData[_realm][_player][n][_LASTY_] = INT(this:GetTop());
797 end
798  
799 function DetachedMiniButtons_OnUpdate()
800 -- calculate the new position
801  
802 --DEFAULT_CHAT_FRAME:AddMessage("UPDATE");
803 if (not _rescanned) then
804 if ((GetTime() - _starttime) > 10) then
805 _rescanned = true;
806 --DetachedMiniButtons_GetChildren("silent");
807 DetachedMiniButtons_DoInit();
808 return;
809 end;
810 end;
811 local n = this:GetName();
812 n = DetachedMiniButtons_Mask(n);
813 if (not _frameList[n]) then
814 return
815 end;
816  
817 if (this.isMoving) then
818 local xpos,ypos = GetCursorPosition()
819 local xmin,ymin = UIParent:GetLeft() , UIParent:GetBottom()
820  
821 local IconPosX = xpos / UIParent:GetEffectiveScale() - xmin
822 local IconPosY = ypos / UIParent:GetEffectiveScale() - ymin
823 IconPosY = IconPosY + (this:GetWidth() / 2);
824 IconPosX = IconPosX - (this:GetWidth() / 2);
825  
826 --local k = 80;
827 --if (FullSizeButtons[this:GetName()]) then
828 -- k = 85
829 --end
830  
831 --xpos = xmin-xpos/UIParent:GetEffectiveScale() + 70
832 --ypos = ypos/UIParent:GetEffectiveScale() - ymin - 70
833 --local angle = math.deg(math.atan2(ypos,xpos))
834 --xpos = -k * cos(angle) + Minimap:GetWidth() / 2
835 --ypos = k * sin(angle) + Minimap:GetHeight() / 2
836 --if (not DetachedMiniButtonsData[_realm][_player][_NODOCK_]) then
837 -- if (math.abs(IconPosX - xpos) < 15) and (math.abs(IconPosY - ypos) < 15) then
838 -- --DEFAULT_CHAT_FRAME:AddMessage("SNAP:");
839 -- IconPosX = xpos
840 -- IconPosY = ypos
841 -- end
842 --end
843 this:ClearAllPoints();
844 --DEFAULT_CHAT_FRAME:AddMessage(IconPosY);
845 this:SetPoint("TOPLEFT",UIParent,"BOTTOMLEFT",INT(IconPosX), INT(IconPosY));
846 this.currentX = INT(this:GetLeft());
847 this.currentY = INT(this:GetTop());
848  
849 if (n == "GameTimeFrame") then
850 this:SetFrameLevel(0);
851 end;
852 if (string.find(n,"RogueTracker")) then
853 this:SetFrameLevel(1);
854 end;
855  
856 else
857 if ((this.currentX ~= INT(this:GetLeft())) and (this.currentY ~= INT(this:GetTop()))) then
858 --DEFAULT_CHAT_FRAME:AddMessage("UPDATE:");
859 this:ClearAllPoints();
860 this:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT",this.currentX, this.currentY);
861 this.currentX = INT(this:GetLeft());
862 this.currentY = INT(this:GetTop());
863 end;
864 end;
865 end
866  
867