vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 simpleMinimap_Movers = simpleMinimap:NewModule("movers")
2 local L = AceLibrary("AceLocale-2.1"):GetInstance("simpleMinimap_Movers", true)
3 --
4 function simpleMinimap_Movers:OnInitialize()
5 self.db = simpleMinimap:AcquireDBNamespace("movers")
6 self.movers = {
7 QuestWatchFrame = "smmQuestMover",
8 DurabilityFrame = "smmDollMover",
9 QuestTimerFrame = "smmTimerMover",
10 smmCaptureMover = "smmCaptureMover"
11 }
12 self.framesDefault = {
13 QuestWatchFrame = { anchor=MinimapCluster, point="TOPRIGHT", rpoint="BOTTOMRIGHT", x=0, y=10 },
14 DurabilityFrame = { anchor=MinimapCluster, point="TOPRIGHT", rpoint="BOTTOMRIGHT", x=40, y=15 },
15 QuestTimerFrame = { anchor=MinimapCluster, point="TOPRIGHT", rpoint="BOTTOMRIGHT", x=10, y=0 },
16 smmCaptureMover = { anchor=MinimapCluster, point="TOPRIGHT", rpoint="BOTTOMRIGHT", x=10, y=15 }
17 }
18 self.defaults = { enabled=true, framePos={} }
19 self.options = {
20 type="group", name=L.movers, desc=L.movers_desc,
21 args={
22 title={
23 type="header", order=1, name="simpleMinimap |cFFFFFFCC"..L.movers
24 },
25 spacer1={
26 type="header", order=2
27 },
28 enabled={
29 type="toggle", order=3, name=L.enabled, desc=L.enabled_desc,
30 get=function() return(self.db.profile.enabled) end,
31 set=function(x) self.db.profile.enabled=x simpleMinimap:ToggleModuleActive(self,x) end
32 },
33 spacer2={
34 type="header", order=4, name="---"
35 },
36 hide={
37 type="toggle", order=10, name=L.hide, desc=L.hide_desc,
38 get=function() return(self.db.profile.hide) end,
39 set=function(x) self.db.profile.hide=x self:UpdateScreen() end
40 }
41 }
42 }
43 simpleMinimap.options.args.modules.args.movers = self.options
44 simpleMinimap:RegisterDefaults("movers", "profile", self.defaults)
45 for n, f in pairs(self.movers) do
46 local movee, mover = getglobal(n), getglobal(f)
47 mover:SetScript("OnDragStart", function() self:FrameDrag(true) end)
48 mover:SetScript("OnDragStop", function() self:FrameDrag(false) end)
49 mover:RegisterForDrag("LeftButton")
50 mover.smmMover = n
51 mover:SetScript("OnEnter", function() GameTooltip:SetOwner(this, "ANCHOR_CURSOR") GameTooltip:SetText(L.drag.." |cFFFFFF99"..this.smmMover) end)
52 mover:SetScript("OnLeave", function() GameTooltip:Hide() end)
53 mover:SetAlpha(0.4)
54 movee:SetMovable(true)
55 end
56 end
57 --
58 function simpleMinimap_Movers:OnEnable()
59 if(self.db.profile.enabled) then
60 self:RegisterEvent("UPDATE_WORLD_STATES")
61 self:UpdateScreen()
62 else
63 simpleMinimap:ToggleModuleActive(self, false)
64 end
65 end
66 --
67 function simpleMinimap_Movers:OnDisable()
68 self:UpdateScreen()
69 end
70 --
71 function simpleMinimap_Movers:FrameDrag(kick)
72 local f = getglobal(this.smmMover)
73 if(kick and not simpleMinimap.db.profile.lock) then
74 f.isMoving = true
75 f:StartMoving()
76 GameTooltip:Hide()
77 elseif(f.isMoving) then
78 f.isMoving = false
79 f:StopMovingOrSizing()
80 self.db.profile.framePos[this.smmMover] = {}
81 self.db.profile.framePos[this.smmMover].x, self.db.profile.framePos[this.smmMover].y = f:GetCenter()
82 end
83 end
84 --
85 function simpleMinimap_Movers:UpdateScreen()
86 for n, f in pairs(self.movers) do
87 local movee, mover = getglobal(n), getglobal(f)
88 if(simpleMinimap:IsModuleActive(self) and self.db.profile.framePos[n]) then
89 simpleMinimap:LockFrame(movee)
90 movee:smm_ClearAllPoints()
91 movee:smm_SetPoint("CENTER", UIParent, "BOTTOMLEFT", self.db.profile.framePos[n].x, self.db.profile.framePos[n].y)
92 elseif(movee.smmTouched) then
93 simpleMinimap:UnlockFrame(movee)
94 movee:ClearAllPoints()
95 movee:SetPoint(self.framesDefault[n].point, self.framesDefault[n].anchor, self.framesDefault[n].rpoint, self.framesDefault[n].x, self.framesDefault[n].y)
96 movee:SetUserPlaced(false)
97 end
98 if(simpleMinimap:IsModuleActive(self) and not self.db.profile.hide and not simpleMinimap.db.profile.lock) then
99 mover:Show()
100 else
101 mover:Hide()
102 end
103 end
104 end
105 --
106 function simpleMinimap_Movers:UPDATE_WORLD_STATES()
107 for i = 1, NUM_EXTENDED_UI_FRAMES do
108 local frame = getglobal("WorldStateCaptureBar"..i)
109 if(frame) then
110 if(simpleMinimap:IsModuleActive(self)) then
111 if(not frame.smmTouched) then
112 simpleMinimap:LockFrame(frame)
113 frame:smm_ClearAllPoints()
114 frame:smm_SetPoint("Center", smmCaptureMover)
115 end
116 elseif(frame.smmTouched) then
117 simpleMinimap:UnlockFrame(frame)
118 end
119 end
120 end
121 end