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