Mercurial > wow > reaction
comparison modules/FuBar_ReActionFu/lib/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.lua @ 30:0d95ce7a9ec2
- added Ace3 externs
- converted ReAction_ConfigUI to use blizzard interface addons panel via AceConfigDialog-3.0
- partially converted FuBar module to LibRock, deprecated it (going to remove it entirely later)
- cleaned up a couple other tidbits
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Wed, 02 Apr 2008 23:31:13 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
29:9c89042bc328 | 30:0d95ce7a9ec2 |
---|---|
1 --[[ | |
2 Name: LibFuBarPlugin-3.0 | |
3 Revision: $Rev: 63707 $ | |
4 Developed by: ckknight (ckknight@gmail.com) | |
5 Website: http://www.wowace.com/ | |
6 Description: Plugin for FuBar. | |
7 Dependencies: LibRock-1.0 | |
8 License: LGPL v2.1 | |
9 ]] | |
10 | |
11 local MAJOR_VERSION = "LibFuBarPlugin-3.0" | |
12 local MINOR_VERSION = tonumber(("$Revision: 63707 $"):match("(%d+)")) - 60000 | |
13 | |
14 if not Rock then error(MAJOR_VERSION .. " requires LibRock-1.0") end | |
15 | |
16 local FuBarPlugin, oldLib = Rock:NewLibrary(MAJOR_VERSION, MINOR_VERSION) | |
17 if not FuBarPlugin then | |
18 return | |
19 end | |
20 | |
21 local SHOW_FUBAR_ICON = "Show FuBar icon" | |
22 local SHOW_FUBAR_ICON_DESC = "Show the FuBar plugin's icon on the panel." | |
23 local SHOW_FUBAR_TEXT = "Show FuBar text" | |
24 local SHOW_FUBAR_TEXT_DESC = "Show the FuBar plugin's text on the panel." | |
25 local SHOW_COLORED_FUBAR_TEXT = "Show colored FuBar text" | |
26 local SHOW_COLORED_FUBAR_TEXT_DESC = "Allow the FuBar plugin to color its text on the panel." | |
27 local DETACH_FUBAR_TOOLTIP = "Detach FuBar tooltip" | |
28 local DETACH_FUBAR_TOOLTIP_DESC = "Detach the FuBar tooltip from the panel." | |
29 local LOCK_FUBAR_TOOLTIP = "Lock tooltip" | |
30 local LOCK_FUBAR_TOOLTIP_DESC = "Lock the tooltips position. When the tooltip is locked, you must use Alt to access it with your mouse." | |
31 local POSITION_ON_FUBAR = "Position on FuBar" | |
32 local POSITION_ON_FUBAR_DESC = "Position the FuBar plugin on the panel." | |
33 local POSITION_LEFT = "Left" | |
34 local POSITION_RIGHT = "Right" | |
35 local POSITION_CENTER = "Center" | |
36 local ATTACH_PLUGIN_TO_MINIMAP = "Attach FuBar plugin to minimap" | |
37 local ATTACH_PLUGIN_TO_MINIMAP_DESC = "Attach the FuBar plugin to the minimap instead of the panel." | |
38 local HIDE_FUBAR_PLUGIN = "Hide FuBar plugin" | |
39 local HIDE_MINIMAP_BUTTON = "Hide minimap button" | |
40 local HIDE_FUBAR_PLUGIN_DESC = "Hide the FuBar plugin from the panel or minimap, leaving the addon running." | |
41 local OTHER = "Other" | |
42 local CLOSE = "Close" | |
43 local CLOSE_DESC = "Close the menu." | |
44 | |
45 if GetLocale() == "zhCN" then | |
46 SHOW_FUBAR_ICON = "显示FuBar图标" | |
47 SHOW_FUBAR_ICON_DESC = "在面板上显示FuBar插件的图标." | |
48 SHOW_FUBAR_TEXT = "显示FuBar文字" | |
49 SHOW_FUBAR_TEXT_DESC = "在面板上显示Fubar插件文字标题" | |
50 SHOW_COLORED_FUBAR_TEXT = "显示彩色文字" | |
51 SHOW_COLORED_FUBAR_TEXT_DESC = "允许插件显示彩色文字." | |
52 DETACH_FUBAR_TOOLTIP = "独立提示信息" | |
53 DETACH_FUBAR_TOOLTIP_DESC = "从面板上独立显示信息" | |
54 LOCK_FUBAR_TOOLTIP = "锁定提示信息" | |
55 LOCK_FUBAR_TOOLTIP_DESC = "锁定提示信息位置.当提示信息被锁定时,你必须要按Alt-鼠标方可查看." | |
56 POSITION_ON_FUBAR = "位置" | |
57 POSITION_ON_FUBAR_DESC = "FuBar插件在面板上的位置." | |
58 POSITION_LEFT = "居左" | |
59 POSITION_RIGHT = "居右" | |
60 POSITION_CENTER = "居中" | |
61 ATTACH_PLUGIN_TO_MINIMAP = "依附在小地图" | |
62 ATTACH_PLUGIN_TO_MINIMAP_DESC = "插件图标依附在小地图而不显示在面板上." | |
63 HIDE_FUBAR_PLUGIN = "隐藏FuBar插件" | |
64 HIDE_MINIMAP_BUTTON = "隐藏小地图按钮" | |
65 HIDE_FUBAR_PLUGIN_DESC = "隐藏在面板或小地图上的FuBar插件,暂定插件工作." | |
66 OTHER = "其他" | |
67 CLOSE = "关闭" | |
68 LOSE_DESC = "关闭目录." | |
69 elseif GetLocale() == "zhTW" then | |
70 SHOW_FUBAR_ICON = "顯示圖示" | |
71 SHOW_FUBAR_ICON_DESC = "在面板上顯示插件圖示。" | |
72 SHOW_FUBAR_TEXT = "顯示文字" | |
73 SHOW_FUBAR_TEXT_DESC = "在面板上顯示插件文字。" | |
74 SHOW_COLORED_FUBAR_TEXT = "允許彩色文字" | |
75 SHOW_COLORED_FUBAR_TEXT_DESC = "允許插件在面板上使用彩色文字。" | |
76 DETACH_FUBAR_TOOLTIP = "獨立提示訊息" | |
77 DETACH_FUBAR_TOOLTIP_DESC = "從面板上獨立提示訊息。" | |
78 LOCK_FUBAR_TOOLTIP = "鎖定提示訊息" | |
79 LOCK_FUBAR_TOOLTIP_DESC = "鎖定提示訊息位置。當提示訊息鎖定時,需要用Alt鍵使用提示訊息的功能。" | |
80 POSITION_ON_FUBAR = "位置" | |
81 POSITION_ON_FUBAR_DESC = "插件在面板上的位置。" | |
82 POSITION_LEFT = "靠左" | |
83 POSITION_RIGHT = "靠右" | |
84 POSITION_CENTER = "置中" | |
85 ATTACH_PLUGIN_TO_MINIMAP = "依附在小地圖" | |
86 ATTACH_PLUGIN_TO_MINIMAP_DESC = "插件圖標依附在小地圖而不顯示在面板上。" | |
87 HIDE_FUBAR_PLUGIN = "隱藏插件" | |
88 HIDE_MINIMAP_BUTTON = "隱藏小地圖按鈕" | |
89 HIDE_FUBAR_PLUGIN_DESC = "在面板或小地圖上隱藏該插件,但保持執行狀態。" | |
90 OTHER = "其他" | |
91 CLOSE = "關閉" | |
92 CLOSE_DESC = "關閉選單。" | |
93 elseif GetLocale() == "koKR" then | |
94 SHOW_FUBAR_ICON = "FuBar 아이콘 표시" | |
95 SHOW_FUBAR_ICON_DESC = "FuBar 패널에 플러그인 아이콘을 표시합니다." | |
96 SHOW_FUBAR_TEXT = "FuBar 텍스트 표시" | |
97 SHOW_FUBAR_TEXT_DESC = "FuBar 페널에 플러그인 텍스트를 표시합니다." | |
98 SHOW_COLORED_FUBAR_TEXT = "색상화된 FuBar 텍스트 표시" | |
99 SHOW_COLORED_FUBAR_TEXT_DESC = "패널의 FuBar 플러그인의 텍스트 색상을 허용합니다." | |
100 DETACH_FUBAR_TOOLTIP = "FuBar 툴팁 분리" | |
101 DETACH_FUBAR_TOOLTIP_DESC = "패널에서 FuBar 툴팁을 분리합니다." | |
102 LOCK_FUBAR_TOOLTIP = "툴팁 고정" | |
103 LOCK_FUBAR_TOOLTIP_DESC = "툴팁 위치를 고정시킵니다. 툴팁이 고정되어 있을때, 마우스로 접근하기 위해 Alt키를 사용하여야 합니다." | |
104 POSITION_ON_FUBAR = "FuBar 위치" | |
105 POSITION_ON_FUBAR_DESC = "패널 위의 FuBar 플러그인의 위치를 설정합니다." | |
106 POSITION_LEFT = "좌측" | |
107 POSITION_RIGHT = "우측" | |
108 POSITION_CENTER = "중앙" | |
109 ATTACH_PLUGIN_TO_MINIMAP = "FuBar 플러그인 미니맵 표시" | |
110 ATTACH_PLUGIN_TO_MINIMAP_DESC = "FuBar 플러그인을 패널 대신 미니맵에 표시합니다." | |
111 HIDE_FUBAR_PLUGIN = "FuBar 플러그인 숨김" | |
112 HIDE_MINIMAP_BUTTON = "미니맵 버튼 숨김" | |
113 HIDE_FUBAR_PLUGIN_DESC = "FuBar 플러그인을 패널이나 미니맵으로 부터 숨김니다." | |
114 OTHER = "기타" | |
115 CLOSE = "닫기" | |
116 CLOSE_DESC = "메뉴를 닫습니다." | |
117 elseif GetLocale() == "frFR" then | |
118 SHOW_FUBAR_ICON = "Afficher l'icône FuBar" | |
119 SHOW_FUBAR_ICON_DESC = "Affiche l'icône du plugin FuBar sur le panneau." | |
120 SHOW_FUBAR_TEXT = "Afficher le texte FuBar" | |
121 SHOW_FUBAR_TEXT_DESC = "Affiche le texte du plugin FuBar sur le panneau." | |
122 SHOW_COLORED_FUBAR_TEXT = "Afficher le texte FuBar coloré" | |
123 SHOW_COLORED_FUBAR_TEXT_DESC = "Autorise le plugin FuBar à colorer son texte sur le panneau." | |
124 DETACH_FUBAR_TOOLTIP = "Détacher l'infobulle FuBar" | |
125 DETACH_FUBAR_TOOLTIP_DESC = "Détache l'infobulle FuBar du panneau." | |
126 LOCK_FUBAR_TOOLTIP = "Verrouiller l'infobulle" | |
127 LOCK_FUBAR_TOOLTIP_DESC = "Verrouille l'infobulle dans sa position actuelle. Quand l'infobulle est verrouillée, vous devez utiliser la touche Alt pour y interagir avec la souris." | |
128 POSITION_ON_FUBAR = "Position sur FuBar" | |
129 POSITION_ON_FUBAR_DESC = "Position du plugin FuBar sur le panneau." | |
130 POSITION_LEFT = "Gauche" | |
131 POSITION_RIGHT = "Droite" | |
132 POSITION_CENTER = "Centre" | |
133 ATTACH_PLUGIN_TO_MINIMAP = "Attacher le plugin FuBar sur la minicarte" | |
134 ATTACH_PLUGIN_TO_MINIMAP_DESC = "Attache le plugin FuBar sur la minicarte au lieu du panneau." | |
135 HIDE_FUBAR_PLUGIN = "Masquer le plugin FuBar" | |
136 HIDE_MINIMAP_BUTTON = "Masquer le bouton de la minicarte" | |
137 HIDE_FUBAR_PLUGIN_DESC = "Masque le plugin FuBar du panneau ou de la minicarte, laissant l'addon fonctionner." | |
138 OTHER = "Autre" | |
139 CLOSE = "Fermer" | |
140 CLOSE_DESC = "Ferme le menu." | |
141 end | |
142 | |
143 -- #AUTODOC_NAMESPACE FuBarPlugin | |
144 | |
145 local precondition, argCheck = Rock:GetContractFunctions(MAJOR_VERSION, "precondition", "argCheck") | |
146 local newList, del = Rock:GetRecyclingFunctions(MAJOR_VERSION, "newList", "del") | |
147 | |
148 FuBarPlugin.pluginToFrame = oldLib and oldLib.pluginToFrame or {} | |
149 local pluginToFrame = FuBarPlugin.pluginToFrame | |
150 FuBarPlugin.pluginToMinimapFrame = oldLib and oldLib.pluginToMinimapFrame or {} | |
151 local pluginToMinimapFrame = FuBarPlugin.pluginToMinimapFrame | |
152 FuBarPlugin.pluginToPanel = oldLib and oldLib.pluginToPanel or {} | |
153 local pluginToPanel = FuBarPlugin.pluginToPanel | |
154 FuBarPlugin.pluginToOptions = oldLib and oldLib.pluginToOptions or {} | |
155 local pluginToOptions = FuBarPlugin.pluginToOptions | |
156 FuBarPlugin.folderNames = oldLib and oldLib.folderNames or {} | |
157 local folderNames = FuBarPlugin.folderNames | |
158 | |
159 local Tablet20 | |
160 local Dewdrop20 | |
161 | |
162 FuBarPlugin.MinimapContainer = oldLib and oldLib.MinimapContainer or {} | |
163 local MinimapContainer = FuBarPlugin.MinimapContainer | |
164 | |
165 local epsilon = 1e-5 | |
166 | |
167 -- #AUTODOC_NAMESPACE FuBarPlugin | |
168 | |
169 --[[--------------------------------------------------------------------------- | |
170 Notes: | |
171 *Set metadata about a certain plugin. | |
172 ; tooltipType : string - | |
173 : "GameTooltip" | |
174 :: Use Blizzard's GameTooltip. (default if not given) | |
175 : "Tablet-2.0" | |
176 :: Use Tablet-2.0. | |
177 : "Custom" | |
178 :: LibFuBarPlugin-3.0 will not provide any extra mechanisms, all done manually. | |
179 ; configType : string - | |
180 : "LibRockConfig-1.0" | |
181 :: Use LibRockConfig-1.0 to show configuration. (default if not given) | |
182 : "Dewdrop-2.0" | |
183 :: Use Dewdrop-2.0. | |
184 ; hasNoText : boolean - If set to true, then it will be a text-less frame. | |
185 ; iconPath : string - the path of the icon to show. | |
186 ; hasNoColor : boolean - If set to true, then it is assumed that no color will be in the text (and thus not show the menu item) | |
187 ; cannotHideText : boolean - If set to true, then the menu item to hide text will not be shown. | |
188 ; overrideMenu : boolean - If set to true, then the menu will not show any of the standard menu items | |
189 ; hideMenuTitle : boolean - If set to true, the plugins name will not be added to the top of the menu as a header. | |
190 ; defaultPosition : string - | |
191 : "LEFT" | |
192 ::show on the left. (default if not given) | |
193 : "CENTER" | |
194 ::show in the center. | |
195 : "RIGHT" | |
196 ::show on the right. | |
197 : "MINIMAP" | |
198 ::show on the minimap. | |
199 ; defaultMinimapPosition : number - Angle on the minimap, in degrees. [0, 360) | |
200 ; clickableTooltip : boolean - Whether you can drag your mouse onto the tooltip and click a line | |
201 ; tooltipHiddenWhenEmpty : boolean - Whether the detached tooltip is hidden when it is empty. | |
202 ; cannotDetachTooltip : boolean - Whether the tooltip cannot be detached from the plugin text. | |
203 ::Normally, a tooltip can detach (if using Tablet-2.0). This should be set if there is no relevant data in the tooltip. | |
204 ; independentProfile : boolean - If set to true, then the profile setting will not be stripped from .OnMenuRequest, and FuBar will not set the plugin's profile when it changes. | |
205 ::non-FuBar-centric plugins should set this to true. | |
206 Arguments: | |
207 string - the key to set | |
208 value - the value to set said key to. | |
209 Example: | |
210 self:SetFuBarOption('tooltipType', "Tablet-2.0") | |
211 -----------------------------------------------------------------------------]] | |
212 function FuBarPlugin:SetFuBarOption(key, value) | |
213 local pluginToOptions_self = pluginToOptions[self] | |
214 if not pluginToOptions_self then | |
215 pluginToOptions_self = {} | |
216 pluginToOptions[self] = pluginToOptions_self | |
217 end | |
218 | |
219 pluginToOptions_self[key] = value | |
220 | |
221 if key == 'tooltipType' then | |
222 if value == "Tablet-2.0" then | |
223 Tablet20 = Rock("Tablet-2.0", false, true) | |
224 if not Tablet20 then | |
225 error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2) | |
226 end | |
227 end | |
228 end | |
229 if key == 'configType' then | |
230 if value == "Dewdrop-2.0" then | |
231 Dewdrop20 = Rock("Dewdrop-2.0", false, true) | |
232 if not Dewdrop20 then | |
233 error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2) | |
234 end | |
235 end | |
236 end | |
237 end | |
238 precondition(FuBarPlugin, 'SetFuBarOption', function(self, key, value) | |
239 argCheck(self, 1, "table") | |
240 argCheck(key, 2, "string") | |
241 argCheck(value, 3, "string", "number", "boolean") | |
242 | |
243 if pluginToOptions[self] and pluginToOptions[self][key] ~= nil then | |
244 error(("Bad argument #2 to `SetFuBarOption'. Cannot specify %q more than once."):format(key), 3) | |
245 end | |
246 end) | |
247 | |
248 local function getPluginOption(object, key, default) | |
249 local pluginToOptions_object = pluginToOptions[object] | |
250 if pluginToOptions_object == nil then | |
251 return default | |
252 end | |
253 local value = pluginToOptions_object[key] | |
254 if value == nil then | |
255 return default | |
256 end | |
257 return value | |
258 end | |
259 | |
260 local good = nil | |
261 local function CheckFuBar() | |
262 if not good then | |
263 if FuBar then | |
264 local version = FuBar.version | |
265 if type(version) == "string" then | |
266 local num = version:match("^(%d+%.?%d*)") | |
267 if num then | |
268 num = tonumber(num) | |
269 good = num >= 3 | |
270 end | |
271 end | |
272 end | |
273 end | |
274 return good | |
275 end | |
276 | |
277 --[[--------------------------------------------------------------------------- | |
278 Returns: | |
279 string - the localized name of the plugin, not including the "FuBar - " part. | |
280 Example | |
281 local title = self:GetTitle() | |
282 -----------------------------------------------------------------------------]] | |
283 function FuBarPlugin:GetTitle() | |
284 local name = self.title or self.name | |
285 if type(name) ~= "string" then | |
286 error("You must provide self.title or self.name", 2) | |
287 end | |
288 local title = name:match("[Ff][Uu][Bb][Aa][Rr]%s*%-%s*(.-)%s*$") or name | |
289 return title:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "") | |
290 end | |
291 | |
292 --[[--------------------------------------------------------------------------- | |
293 Returns: | |
294 string - name of the plugin. | |
295 Notes: | |
296 This is here for FuBar core to communicate properly. | |
297 Example: | |
298 local name = self:GetName() | |
299 -----------------------------------------------------------------------------]] | |
300 function FuBarPlugin:GetName() | |
301 return self.name | |
302 end | |
303 | |
304 --[[--------------------------------------------------------------------------- | |
305 Returns: | |
306 string - category of the plugin. | |
307 Notes: | |
308 This is here for FuBar core to communicate properly. | |
309 Example: | |
310 local category = self:GetCategory() | |
311 -----------------------------------------------------------------------------]] | |
312 function FuBarPlugin:GetCategory() | |
313 return self.category or OTHER | |
314 end | |
315 | |
316 --[[--------------------------------------------------------------------------- | |
317 Returns: | |
318 frame - frame for the plugin. | |
319 Notes: | |
320 This is here for FuBar core to communicate properly. | |
321 Example: | |
322 local frame = self:GetFrame() | |
323 -----------------------------------------------------------------------------]] | |
324 function FuBarPlugin:GetFrame() | |
325 return pluginToFrame[self] | |
326 end | |
327 | |
328 --[[--------------------------------------------------------------------------- | |
329 Returns: | |
330 object - panel for the plugin. | |
331 Notes: | |
332 This is here for FuBar core to communicate properly. | |
333 Example: | |
334 local panel = self:GetPanel() | |
335 -----------------------------------------------------------------------------]] | |
336 function FuBarPlugin:GetPanel() | |
337 return pluginToPanel[self] | |
338 end | |
339 | |
340 local function getLazyDatabaseValueDefault(object, value, ...) | |
341 local object_db = object.db | |
342 if type(object_db) ~= "table" then | |
343 return value | |
344 end | |
345 local current = object_db.profile | |
346 for i = 1, select('#', ...) do | |
347 -- traverse through, make sure tables exist. | |
348 if type(current) ~= "table" then | |
349 return value | |
350 end | |
351 current = current[(select(i, ...))] | |
352 end | |
353 if current == nil then | |
354 return value | |
355 else | |
356 return current | |
357 end | |
358 end | |
359 | |
360 local function getLazyDatabaseValue(object, ...) | |
361 return getLazyDatabaseValueDefault(object, nil, ...) | |
362 end | |
363 | |
364 local function setLazyDatabaseValue(object, value, ...) | |
365 local object_db = object.db | |
366 if type(object_db) ~= "table" then | |
367 return nil | |
368 end | |
369 local current = object_db.profile | |
370 if type(current) ~= "table" then | |
371 return nil | |
372 end | |
373 local n = select('#', ...) | |
374 for i = 1, n-1 do | |
375 -- traverse through, create tables if necessary. | |
376 local nextOne = current[(select(i, ...))] | |
377 if type(nextOne) ~= "table" then | |
378 if nextOne ~= nil then | |
379 return nil | |
380 end | |
381 nextOne = {} | |
382 current[(select(i, ...))] = nextOne | |
383 end | |
384 current = nextOne | |
385 end | |
386 current[select(n, ...)] = value | |
387 return true | |
388 end | |
389 | |
390 --[[--------------------------------------------------------------------------- | |
391 Returns: | |
392 boolean - whether the text has color applied. | |
393 Example: | |
394 local colored = self:IsFuBarTextColored() | |
395 -----------------------------------------------------------------------------]] | |
396 function FuBarPlugin:IsFuBarTextColored() | |
397 return not getLazyDatabaseValue(self, 'uncolored') | |
398 end | |
399 | |
400 --[[--------------------------------------------------------------------------- | |
401 Notes: | |
402 Toggles whether the text has color applied | |
403 Example: | |
404 self:ToggleTextColored() | |
405 -----------------------------------------------------------------------------]] | |
406 function FuBarPlugin:ToggleFuBarTextColored() | |
407 if not setLazyDatabaseValue(self, not getLazyDatabaseValue(self, 'uncolored') or nil, 'uncolored') then | |
408 error(("%s: Cannot change text color if self.db is not available."):format(self:GetTitle()), 2) | |
409 end | |
410 self:UpdateFuBarText() | |
411 end | |
412 | |
413 --[[--------------------------------------------------------------------------- | |
414 Returns: | |
415 boolean - whether the plugin is attached to the minimap. | |
416 Example: | |
417 local attached = self:IsMinimapAttached() | |
418 -----------------------------------------------------------------------------]] | |
419 function FuBarPlugin:IsFuBarMinimapAttached() | |
420 if not CheckFuBar() then | |
421 return true | |
422 end | |
423 return pluginToPanel[self] == MinimapContainer | |
424 end | |
425 | |
426 --[[--------------------------------------------------------------------------- | |
427 Notes: | |
428 Toggles whether the plugin is attached to the minimap. | |
429 Example: | |
430 self:ToggleMinimapAttached() | |
431 -----------------------------------------------------------------------------]] | |
432 function FuBarPlugin:ToggleFuBarMinimapAttached() | |
433 if CheckFuBar() and not getPluginOption(self, 'cannotAttachToMinimap', false) then | |
434 local panel = pluginToPanel[self] | |
435 local value = panel == MinimapContainer | |
436 if value then | |
437 panel:RemovePlugin(self) | |
438 local defaultPosition = getPluginOption(self, 'defaultPosition', "LEFT") | |
439 FuBar:GetPanel(1):AddPlugin(self, nil, defaultPosition == "MINIMAP" and "LEFT" or defaultPosition) | |
440 else | |
441 if panel then | |
442 panel:RemovePlugin(self) | |
443 end | |
444 MinimapContainer:AddPlugin(self) | |
445 end | |
446 end | |
447 end | |
448 | |
449 --[[--------------------------------------------------------------------------- | |
450 Notes: | |
451 Calls :UpdateFuBarText() and :UpdateFuBarTooltip(), in that order. | |
452 Example: | |
453 self:UpdateFuBarPlugin() | |
454 -----------------------------------------------------------------------------]] | |
455 function FuBarPlugin:UpdateFuBarPlugin() | |
456 self:UpdateFuBarText() | |
457 self:UpdateFuBarTooltip() | |
458 end | |
459 | |
460 --[[--------------------------------------------------------------------------- | |
461 Notes: | |
462 * Calls :OnUpdateFuBarText() if it is available and the plugin is not disabled. | |
463 * It is expected to update the icon in :OnUpdateFuBarText as well as text. | |
464 Example: | |
465 self:UpdateFuBarText() | |
466 -----------------------------------------------------------------------------]] | |
467 function FuBarPlugin:UpdateFuBarText() | |
468 if type(self.OnUpdateFuBarText) == "function" then | |
469 if not self:IsDisabled() then | |
470 self:OnUpdateFuBarText() | |
471 end | |
472 elseif self:IsFuBarTextShown() then | |
473 self:SetFuBarText(self:GetTitle()) | |
474 end | |
475 end | |
476 | |
477 local function Tablet20_point(frame) | |
478 if frame:GetTop() > GetScreenHeight() / 2 then | |
479 local x = frame:GetCenter() | |
480 if x < GetScreenWidth() / 3 then | |
481 return "TOPLEFT", "BOTTOMLEFT" | |
482 elseif x < GetScreenWidth() * 2 / 3 then | |
483 return "TOP", "BOTTOM" | |
484 else | |
485 return "TOPRIGHT", "BOTTOMRIGHT" | |
486 end | |
487 else | |
488 local x = frame:GetCenter() | |
489 if x < GetScreenWidth() / 3 then | |
490 return "BOTTOMLEFT", "TOPLEFT" | |
491 elseif x < GetScreenWidth() * 2 / 3 then | |
492 return "BOTTOM", "TOP" | |
493 else | |
494 return "BOTTOMRIGHT", "TOPRIGHT" | |
495 end | |
496 end | |
497 end | |
498 | |
499 local function RegisterTablet20(self) | |
500 local frame = pluginToFrame[self] | |
501 if not Tablet20:IsRegistered(frame) then | |
502 local db = getLazyDatabaseValue(self) | |
503 if db and not db.detachedTooltip then | |
504 db.detachedTooltip = {} | |
505 end | |
506 Tablet20:Register(frame, | |
507 'children', function() | |
508 Tablet20:SetTitle(self:GetTitle()) | |
509 if type(self.OnUpdateFuBarTooltip) == "function" then | |
510 if not self:IsDisabled() then | |
511 self:OnUpdateFuBarTooltip() | |
512 end | |
513 end | |
514 end, | |
515 'clickable', getPluginOption(self, 'clickableTooltip', false), | |
516 'data', CheckFuBar() and FuBar.db.profile.tooltip or db and db.detachedTooltip or {}, | |
517 'detachedData', db and db.detachedTooltip or {}, | |
518 'point', Tablet20_point, | |
519 'menu', self.OnMenuRequest and function(level, value, valueN_1, valueN_2, valueN_3, valueN_4) | |
520 if level == 1 then | |
521 local name = tostring(self) | |
522 if not name:find('^table:') then | |
523 name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1") | |
524 Rock("Dewdrop-2.0"):AddLine( | |
525 'text', name, | |
526 'isTitle', true | |
527 ) | |
528 end | |
529 end | |
530 if type(self.OnMenuRequest) == "function" then | |
531 self:OnMenuRequest(level, value, true, valueN_1, valueN_2, valueN_3, valueN_4) | |
532 elseif type(self.OnMenuRequest) == "table" then | |
533 Rock("Dewdrop-2.0"):FeedAceOptionsTable(self.OnMenuRequest) | |
534 end | |
535 end, | |
536 'hideWhenEmpty', getPluginOption(self, 'tooltipHiddenWhenEmpty', false) | |
537 ) | |
538 local func = pluginToFrame[self]:GetScript("OnEnter") | |
539 frame:SetScript("OnEnter", function(this, ...) | |
540 -- HACK | |
541 func(this, ...) | |
542 | |
543 if FuBar and FuBar.IsHidingTooltipsInCombat and FuBar:IsHidingTooltipsInCombat() and InCombatLockdown() then | |
544 if Tablet20:IsAttached(this) then | |
545 Tablet20:Close(this) | |
546 end | |
547 end | |
548 end) | |
549 end | |
550 end | |
551 | |
552 --[[--------------------------------------------------------------------------- | |
553 Notes: | |
554 Calls :OnUpdateFuBarTooltip() if it is available, the plugin is not disabled, and the tooltip is shown. | |
555 Example: | |
556 self:UpdateFuBarTooltip() | |
557 -----------------------------------------------------------------------------]] | |
558 function FuBarPlugin:UpdateFuBarTooltip() | |
559 local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip") | |
560 | |
561 if tooltipType == "GameTooltip" then | |
562 local frame = self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self] | |
563 if not GameTooltip:IsOwned(frame) then | |
564 return | |
565 end | |
566 GameTooltip:Hide() | |
567 | |
568 local anchor | |
569 if frame:GetTop() > GetScreenHeight() / 2 then | |
570 local x = frame:GetCenter() | |
571 if x < GetScreenWidth() / 2 then | |
572 anchor = "ANCHOR_BOTTOMRIGHT" | |
573 else | |
574 anchor = "ANCHOR_BOTTOMLEFT" | |
575 end | |
576 else | |
577 local x = frame:GetCenter() | |
578 if x < GetScreenWidth() / 2 then | |
579 anchor = "ANCHOR_TOPLEFT" | |
580 else | |
581 anchor = "ANCHOR_TOPRIGHT" | |
582 end | |
583 end | |
584 GameTooltip:SetOwner(frame, anchor) | |
585 if type(self.OnUpdateFuBarTooltip) == "function" and not self:IsDisabled() then | |
586 self:OnUpdateFuBarTooltip() | |
587 end | |
588 GameTooltip:Show() | |
589 return | |
590 elseif tooltipType == "Custom" then | |
591 if type(self.OnUpdateFuBarTooltip) == "function" and not self:IsDisabled() then | |
592 self:OnUpdateFuBarTooltip() | |
593 end | |
594 return | |
595 elseif tooltipType == "Tablet-2.0" then | |
596 RegisterTablet20(self) | |
597 if self:IsFuBarMinimapAttached() and not self:IsFuBarTooltipDetached() and pluginToMinimapFrame[self] then | |
598 Tablet20:Refresh(pluginToMinimapFrame[self]) | |
599 else | |
600 Tablet20:Refresh(pluginToFrame[self]) | |
601 end | |
602 elseif tooltipType == "None" then | |
603 return | |
604 else | |
605 error(("Unknown %s option for %q: %q"):format(MAJOR_VERSION, 'tooltipType', tostring(tooltipType)), 2) | |
606 end | |
607 end | |
608 | |
609 --[[--------------------------------------------------------------------------- | |
610 Notes: | |
611 Shows the plugin, enables the plugin if previously disabled, and calls :UpdateFuBarPlugin(). | |
612 Example: | |
613 self:Show() | |
614 -----------------------------------------------------------------------------]] | |
615 function FuBarPlugin:Show(panelId) | |
616 if pluginToFrame[self]:IsShown() or (pluginToMinimapFrame[self] and pluginToMinimapFrame[self]:IsShown()) then | |
617 return | |
618 end | |
619 if panelId ~= false then | |
620 setLazyDatabaseValue(self, nil, 'hidden') | |
621 end | |
622 if self.IsActive and not self:IsActive() then | |
623 self.panelIdTmp = panelId | |
624 self:ToggleActive() | |
625 self.panelIdTmp = nil | |
626 setLazyDatabaseValue(self, nil, 'disabled') | |
627 elseif not getLazyDatabaseValue(self, 'hidden') then | |
628 if panelId == 0 or not CheckFuBar() then | |
629 MinimapContainer:AddPlugin(self) | |
630 else | |
631 FuBar:ShowPlugin(self, panelId or self.panelIdTmp) | |
632 end | |
633 if not getPluginOption(self, 'userDefinedFrame', false) then | |
634 if not self:IsFuBarTextShown() then | |
635 local text = pluginToFrame[self].text | |
636 text:SetText("") | |
637 text:SetWidth(epsilon) | |
638 text:Hide() | |
639 end | |
640 if not self:IsFuBarIconShown() then | |
641 local icon = pluginToFrame[self].icon | |
642 icon:SetWidth(epsilon) | |
643 icon:Hide() | |
644 end | |
645 end | |
646 self:UpdateFuBarPlugin() | |
647 end | |
648 end | |
649 | |
650 --[[--------------------------------------------------------------------------- | |
651 Notes: | |
652 Hides the plugin, disables the plugin if cannot hide without standby. | |
653 Arguments: | |
654 [optional] boolean - internal variable. Do not set this. | |
655 Example: | |
656 self:Hide() | |
657 -----------------------------------------------------------------------------]] | |
658 function FuBarPlugin:Hide(check) | |
659 if not pluginToFrame[self]:IsShown() and (not pluginToMinimapFrame[self] or not pluginToMinimapFrame[self]:IsShown()) then | |
660 return | |
661 end | |
662 local hideWithoutStandby = getPluginOption(self, 'hideWithoutStandby', false) | |
663 if hideWithoutStandby and check ~= false then | |
664 setLazyDatabaseValue(self, true, 'hidden') | |
665 end | |
666 if not hideWithoutStandby then | |
667 if getPluginOption(self, 'tooltipType', "GameTooltip") == "Tablet-2.0" and not getPluginOption(self, 'cannotDetachTooltip', false) and self:IsFuBarTooltipDetached() and getLazyDatabaseValue(self, 'detachedTooltip', 'detached') then | |
668 self:ReattachTooltip() | |
669 setLazyDatabaseValue(self, true, 'detachedTooltip', 'detached') | |
670 end | |
671 if self.IsActive and self:IsActive() and self.ToggleActive and (not CheckFuBar() or not FuBar:IsChangingProfile()) then | |
672 self:ToggleActive() | |
673 end | |
674 end | |
675 if pluginToPanel[self] then | |
676 pluginToPanel[self]:RemovePlugin(self) | |
677 end | |
678 pluginToFrame[self]:Hide() | |
679 if pluginToMinimapFrame[self] then | |
680 pluginToMinimapFrame[self]:Hide() | |
681 end | |
682 end | |
683 | |
684 --[[--------------------------------------------------------------------------- | |
685 Notes: | |
686 Sets the path to the icon for the plugin. | |
687 Arguments: | |
688 string or nil - The path to the icon. If nil, then no icon. | |
689 Example: | |
690 self:SetFuBarIcon("Interface\\AddOns\\MyAddon\\otherIcon") | |
691 -----------------------------------------------------------------------------]] | |
692 function FuBarPlugin:SetFuBarIcon(path) | |
693 if not path then | |
694 return | |
695 end | |
696 if not pluginToFrame[self] or not pluginToFrame[self].icon then | |
697 return | |
698 end | |
699 if path:match([[^Interface\Icons\]]) then | |
700 pluginToFrame[self].icon:SetTexCoord(0.05, 0.95, 0.05, 0.95) | |
701 else | |
702 pluginToFrame[self].icon:SetTexCoord(0, 1, 0, 1) | |
703 end | |
704 pluginToFrame[self].icon:SetTexture(path) | |
705 if pluginToMinimapFrame[self] and pluginToMinimapFrame[self].icon then | |
706 if path:match([[^Interface\Icons\]]) then | |
707 pluginToMinimapFrame[self].icon:SetTexCoord(0.05, 0.95, 0.05, 0.95) | |
708 else | |
709 pluginToMinimapFrame[self].icon:SetTexCoord(0, 1, 0, 1) | |
710 end | |
711 pluginToMinimapFrame[self].icon:SetTexture(path) | |
712 end | |
713 end | |
714 precondition(FuBarPlugin, 'SetFuBarIcon', function(self, path) | |
715 if not path then | |
716 return | |
717 end | |
718 argCheck(path, 2, "string", "nil") | |
719 if not getPluginOption(self, 'iconPath', false) then | |
720 error(("%s: Cannot set icon unless 'iconPath' is set."):format(self:GetTitle()), 3) | |
721 end | |
722 end) | |
723 | |
724 --[[--------------------------------------------------------------------------- | |
725 Returns: | |
726 string or nil - The path to the icon for the plugin. If nil, then no icon. | |
727 Example: | |
728 local path = self:GetFuBarIcon() | |
729 -----------------------------------------------------------------------------]] | |
730 function FuBarPlugin:GetFuBarIcon() | |
731 if getPluginOption(self, 'iconPath', false) then | |
732 return pluginToFrame[self] and pluginToFrame[self].icon and pluginToFrame[self].icon:GetTexture() | |
733 end | |
734 end | |
735 | |
736 --[[--------------------------------------------------------------------------- | |
737 Notes: | |
738 Checks the current width of the icon and text, then updates frame to expand/shrink to it if necessary. | |
739 Arguments: | |
740 [optional] boolean - if true, Shrink/expand no matter what, otherwise if the width is less than 8 pixels smaller, don't shrink. | |
741 Example: | |
742 self:CheckWidth(true) | |
743 -----------------------------------------------------------------------------]] | |
744 function FuBarPlugin:CheckWidth(force) | |
745 local frame = pluginToFrame[self] | |
746 if not frame then | |
747 return | |
748 end | |
749 local icon = frame.icon | |
750 local text = frame.text | |
751 if (not icon or not icon:IsShown()) and (not text or not text:IsShown()) then | |
752 return | |
753 end | |
754 | |
755 local db = getLazyDatabaseValue(self) | |
756 | |
757 if (db and not self:IsFuBarIconShown()) or not getPluginOption(self, 'iconPath', false) then | |
758 icon:SetWidth(epsilon) | |
759 end | |
760 local width | |
761 if not getPluginOption(self, 'hasNoText', false) then | |
762 text:SetHeight(0) | |
763 text:SetWidth(500) | |
764 width = text:GetStringWidth() + 1 | |
765 text:SetWidth(width) | |
766 text:SetHeight(text:GetHeight()) | |
767 end | |
768 local panel = pluginToPanel[self] | |
769 if getPluginOption(self, 'hasNoText', false) or not text:IsShown() then | |
770 frame:SetWidth(icon:GetWidth()) | |
771 if panel and panel:GetPluginSide(self) == "CENTER" then | |
772 panel:UpdateCenteredPosition() | |
773 end | |
774 elseif force or not frame.textWidth or frame.textWidth < width or frame.textWidth - 8 > width then | |
775 frame.textWidth = width | |
776 text:SetWidth(width) | |
777 if icon and icon:IsShown() then | |
778 frame:SetWidth(width + icon:GetWidth()) | |
779 else | |
780 frame:SetWidth(width) | |
781 end | |
782 if panel and panel:GetPluginSide(self) == "CENTER" then | |
783 panel:UpdateCenteredPosition() | |
784 end | |
785 end | |
786 end | |
787 precondition(FuBarPlugin, 'CheckWidth', function(self, force) | |
788 argCheck(force, 2, "boolean", "nil") | |
789 end) | |
790 | |
791 --[[--------------------------------------------------------------------------- | |
792 Notes: | |
793 Sets the text of the plugin. Should only be called from within :OnFuBarUpdateText() | |
794 Arguments: | |
795 string - text to set the plugin to. If not given, set to title. | |
796 Example: | |
797 myAddon.OnFuBarUpdateText = function(self) | |
798 self:SetFuBarText("Hello") | |
799 fend | |
800 -----------------------------------------------------------------------------]] | |
801 function FuBarPlugin:SetFuBarText(text) | |
802 local frame = pluginToFrame[self] | |
803 if not frame or not frame.text then | |
804 return | |
805 end | |
806 if text == "" then | |
807 if getPluginOption(self, 'iconPath', false) then | |
808 self:ShowFuBarIcon() | |
809 else | |
810 text = self:GetTitle() | |
811 end | |
812 end | |
813 if not self:IsFuBarTextColored() then | |
814 text = text:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "") | |
815 end | |
816 frame.text:SetText(text) | |
817 self:CheckWidth() | |
818 end | |
819 precondition(FuBarPlugin, 'SetFuBarText', function(self, text) | |
820 local frame = pluginToFrame[self] | |
821 if not frame or not frame.text then | |
822 return | |
823 end | |
824 if getPluginOption(self, 'hasNoText', false) then | |
825 error(("%s: Cannot set text if 'hasNoText' has been set."):format(self:GetTitle()), 3) | |
826 end | |
827 argCheck(text, 2, "string", "number") | |
828 end) | |
829 | |
830 --[[--------------------------------------------------------------------------- | |
831 Returns: | |
832 string - The current text of the plugin. | |
833 Example: | |
834 local text = self:GetFuBarText() | |
835 -----------------------------------------------------------------------------]] | |
836 function FuBarPlugin:GetFuBarText() | |
837 local frame = pluginToFrame[self] | |
838 if not frame or not frame.text then | |
839 error(("%s: Cannot get text without a text frame."):format(self:GetTitle()), 2) | |
840 end | |
841 if not getPluginOption(self, 'hasNoText', false) then | |
842 return frame.text:GetText() or "" | |
843 end | |
844 end | |
845 | |
846 --[[--------------------------------------------------------------------------- | |
847 Returns: | |
848 boolean - whether the icon for the plugin is showing. | |
849 Example: | |
850 local isIconShowing = self:IsFuBarIconShown() | |
851 -----------------------------------------------------------------------------]] | |
852 function FuBarPlugin:IsFuBarIconShown() | |
853 if not getPluginOption(self, 'iconPath', false) then | |
854 return false | |
855 elseif getPluginOption(self, 'hasNoText', false) then | |
856 return true | |
857 end | |
858 return not not getLazyDatabaseValueDefault(self, true, 'showIcon') | |
859 end | |
860 | |
861 --[[--------------------------------------------------------------------------- | |
862 Notes: | |
863 Toggles whether the icon for the plugin is showing. | |
864 Example: | |
865 self:ToggleFuBarIconShown() | |
866 -----------------------------------------------------------------------------]] | |
867 function FuBarPlugin:ToggleFuBarIconShown() | |
868 local frame = pluginToFrame[self] | |
869 local icon = frame and frame.icon | |
870 local text = frame and frame.text | |
871 if not icon then | |
872 error(("%s: Cannot toggle icon without an icon frame."):format(self:GetTitle()), 2) | |
873 elseif not text then | |
874 error(("%s: Cannot toggle icon without a text frame."):format(self:GetTitle()), 2) | |
875 elseif not getPluginOption(self, 'iconPath', false) then | |
876 error(("%s: Cannot show icon unless 'iconPath' is set."):format(self:GetTitle()), 2) | |
877 elseif getPluginOption(self, 'hasNoText', false) then | |
878 error(("%s: Cannot show icon if 'hasNoText' is set."):format(self:GetTitle()), 2) | |
879 elseif not getLazyDatabaseValue(self) then | |
880 error(("%s: Cannot hide icon if self.db is not available."):format(self:GetTitle()), 2) | |
881 end | |
882 local value = not self:IsFuBarIconShown() | |
883 setLazyDatabaseValue(self, value, 'showIcon') | |
884 if value then | |
885 if not self:IsFuBarTextShown() and text:IsShown() and text:GetText() == self:GetTitle() then | |
886 text:Hide() | |
887 text:SetText("") | |
888 end | |
889 icon:Show() | |
890 icon:SetWidth(pluginToFrame[self].icon:GetHeight()) | |
891 self:UpdateFuBarText() | |
892 else | |
893 if not text:IsShown() or not text:GetText() or text:GetText() == "" then | |
894 text:Show() | |
895 text:SetText(self:GetTitle()) | |
896 end | |
897 icon:Hide() | |
898 icon:SetWidth(epsilon) | |
899 end | |
900 self:CheckWidth(true) | |
901 return value | |
902 end | |
903 | |
904 --[[--------------------------------------------------------------------------- | |
905 Notes: | |
906 Shows the icon of the plugin if hidden. | |
907 Example: | |
908 self:ShowFuBarIcon() | |
909 -----------------------------------------------------------------------------]] | |
910 function FuBarPlugin:ShowFuBarIcon() | |
911 if not self:IsFuBarIconShown() then | |
912 self:ToggleFuBarIconShown() | |
913 end | |
914 end | |
915 | |
916 --[[--------------------------------------------------------------------------- | |
917 Notes: | |
918 Hides the icon of the plugin if shown. | |
919 Example: | |
920 self:HideFuBarIcon() | |
921 -----------------------------------------------------------------------------]] | |
922 function FuBarPlugin:HideFuBarIcon() | |
923 if self:IsFuBarIconShown() then | |
924 self:ToggleFuBarIconShown() | |
925 end | |
926 end | |
927 | |
928 --[[--------------------------------------------------------------------------- | |
929 Returns: | |
930 boolean - whether the text for the plugin is showing. | |
931 Example: | |
932 local isTextShowing = self:IsFuBarTextShown() | |
933 -----------------------------------------------------------------------------]] | |
934 function FuBarPlugin:IsFuBarTextShown() | |
935 if getPluginOption(self, 'hasNoText', false) then | |
936 return false | |
937 elseif not getPluginOption(self, 'iconPath', false) then | |
938 return true | |
939 end | |
940 return not not getLazyDatabaseValueDefault(self, true, 'showText') | |
941 end | |
942 | |
943 --[[--------------------------------------------------------------------------- | |
944 Notes: | |
945 Toggles whether the text for the plugin is showing. | |
946 Example: | |
947 self:ToggleFuBarTextShown() | |
948 -----------------------------------------------------------------------------]] | |
949 function FuBarPlugin:ToggleFuBarTextShown() | |
950 local frame = pluginToFrame[self] | |
951 local icon = frame and frame.icon | |
952 local text = frame and frame.text | |
953 if not icon then | |
954 error(("%s: Cannot toggle text without an icon frame."):format(self:GetTitle()), 2) | |
955 elseif not text then | |
956 error(("%s: Cannot toggle text without a text frame."):format(self:GetTitle()), 2) | |
957 elseif getPluginOption(self, 'cannotHideText', false) then | |
958 error(("%s: Cannot toggle text if 'cannotHideText' is set."):format(self:GetTitle()), 2) | |
959 elseif not getPluginOption(self, 'iconPath', false) then | |
960 error(("%s: Cannot toggle text unless 'iconPath' is set."):format(self:GetTitle()), 2) | |
961 elseif getPluginOption(self, 'hasNoText', false) then | |
962 error(("%s: Cannot toggle text if 'hasNoText' is set."):format(self:GetTitle()), 2) | |
963 elseif not getLazyDatabaseValue(self) then | |
964 error(("%s: Cannot toggle text if self.db is not available."):format(self:GetTitle()), 2) | |
965 end | |
966 local value = not self:IsFuBarTextShown() | |
967 setLazyDatabaseValue(self, value, 'showText') | |
968 if value then | |
969 text:Show() | |
970 self:UpdateFuBarText() | |
971 else | |
972 text:SetText("") | |
973 text:SetWidth(epsilon) | |
974 text:Hide() | |
975 self:ShowFuBarIcon() | |
976 end | |
977 self:CheckWidth(true) | |
978 return value | |
979 end | |
980 | |
981 --[[--------------------------------------------------------------------------- | |
982 Notes: | |
983 Shows the text of the plugin if hidden. | |
984 Example: | |
985 self:ShowFuBarText() | |
986 -----------------------------------------------------------------------------]] | |
987 function FuBarPlugin:ShowFuBarText() | |
988 if not self:IsFuBarTextShown() then | |
989 self:ToggleFuBarTextShown() | |
990 end | |
991 end | |
992 | |
993 --[[--------------------------------------------------------------------------- | |
994 Notes: | |
995 Hides the text of the plugin if shown. | |
996 Example: | |
997 self:HideFuBarText() | |
998 -----------------------------------------------------------------------------]] | |
999 function FuBarPlugin:HideFuBarText() | |
1000 if self:IsFuBarTextShown() then | |
1001 self:ToggleFuBarTextShown() | |
1002 end | |
1003 end | |
1004 | |
1005 --[[--------------------------------------------------------------------------- | |
1006 Returns: | |
1007 string - default position of the plugin. | |
1008 Notes: | |
1009 This is here for FuBar core to communicate properly. | |
1010 Example: | |
1011 local pos = self:GetDefaultPosition() | |
1012 -----------------------------------------------------------------------------]] | |
1013 function FuBarPlugin:GetDefaultPosition() | |
1014 return getPluginOption(self, 'defaultPosition', "LEFT") | |
1015 end | |
1016 | |
1017 --[[--------------------------------------------------------------------------- | |
1018 Returns: | |
1019 boolean - Whether the tooltip is detached. | |
1020 Example: | |
1021 local detached = self:IsFuBarTooltipDetached() | |
1022 -----------------------------------------------------------------------------]] | |
1023 function FuBarPlugin:IsFuBarTooltipDetached() | |
1024 local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip") | |
1025 if tooltipType ~= "Tablet-2.0" then | |
1026 return | |
1027 end | |
1028 | |
1029 RegisterTablet20(self) | |
1030 return not Tablet20:IsAttached(pluginToFrame[self]) | |
1031 end | |
1032 | |
1033 --[[--------------------------------------------------------------------------- | |
1034 Notes: | |
1035 Toggles whether the tooltip is detached. | |
1036 Example: | |
1037 self:ToggleFuBarTooltipDetached() | |
1038 -----------------------------------------------------------------------------]] | |
1039 function FuBarPlugin:ToggleFuBarTooltipDetached() | |
1040 local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip") | |
1041 if tooltipType ~= "Tablet-2.0" then | |
1042 return | |
1043 end | |
1044 | |
1045 RegisterTablet20(self) | |
1046 if Tablet20:IsAttached(pluginToFrame[self]) then | |
1047 Tablet20:Detach(pluginToFrame[self]) | |
1048 else | |
1049 Tablet20:Attach(pluginToFrame[self]) | |
1050 end | |
1051 end | |
1052 | |
1053 --[[--------------------------------------------------------------------------- | |
1054 Notes: | |
1055 * Detaches the tooltip from the plugin. | |
1056 * This does nothing if already detached. | |
1057 Example: | |
1058 self:DetachFuBarTooltip() | |
1059 -----------------------------------------------------------------------------]] | |
1060 function FuBarPlugin:DetachFuBarTooltip() | |
1061 if not self:IsFuBarTooltipDetached() then | |
1062 self:ToggleFuBarTooltipDetached() | |
1063 end | |
1064 end | |
1065 | |
1066 --[[--------------------------------------------------------------------------- | |
1067 Notes: | |
1068 Reattaches the tooltip to the plugin. | |
1069 This does nothing if already attached. | |
1070 Example: | |
1071 self:ReattachFuBarTooltip() | |
1072 -----------------------------------------------------------------------------]] | |
1073 function FuBarPlugin:ReattachFuBarTooltip() | |
1074 if self:IsFuBarTooltipDetached() then | |
1075 self:ToggleFuBarTooltipDetached() | |
1076 end | |
1077 end | |
1078 | |
1079 local function IsCorrectPanel(panel) | |
1080 if type(panel) ~= "table" then | |
1081 return false | |
1082 elseif type(panel.AddPlugin) ~= "function" then | |
1083 return false | |
1084 elseif type(panel.RemovePlugin) ~= "function" then | |
1085 return false | |
1086 elseif type(panel.GetNumPlugins) ~= "function" then | |
1087 return false | |
1088 elseif type(panel:GetNumPlugins()) ~= "number" then | |
1089 return false | |
1090 elseif type(panel.GetPlugin) ~= "function" then | |
1091 return false | |
1092 elseif type(panel.HasPlugin) ~= "function" then | |
1093 return false | |
1094 elseif type(panel.GetPluginSide) ~= "function" then | |
1095 return false | |
1096 end | |
1097 return true | |
1098 end | |
1099 | |
1100 -- #NODOC | |
1101 -- this is used internally by FuBar | |
1102 function FuBarPlugin:SetPanel(panel) | |
1103 pluginToPanel[self] = panel | |
1104 end | |
1105 precondition(FuBarPlugin, 'SetPanel', function(self, panel) | |
1106 argCheck(panel, 2, "table", "nil") | |
1107 if panel and not IsCorrectPanel(panel) then | |
1108 error("Bad argument #2 to `SetPanel'. Panel does not have the correct API.", 3) | |
1109 end | |
1110 end) | |
1111 | |
1112 -- #NODOC | |
1113 -- this is used internally by FuBar | |
1114 function FuBarPlugin:SetFontSize(size) | |
1115 if getPluginOption(self, 'userDefinedFrame', false) then | |
1116 error(("%sYou must provide a :SetFontSize(size) method if you have 'userDefinedFrame' set."):format(self.name and self.name .. ": " or ""), 2) | |
1117 end | |
1118 if getPluginOption(self, 'iconPath', false) then | |
1119 local frame = pluginToFrame[self] | |
1120 local icon = frame and frame.icon | |
1121 if not icon then | |
1122 error(("%sno icon frame found."):format(self.name and self.name .. ": " or ""), 2) | |
1123 end | |
1124 icon:SetWidth(size + 3) | |
1125 icon:SetHeight(size + 3) | |
1126 end | |
1127 if not getPluginOption(self, 'hasNoText', false) then | |
1128 local frame = pluginToFrame[self] | |
1129 local text = frame and frame.text | |
1130 if not text then | |
1131 error(("%sno text frame found."):format(self.name and self.name .. ": " or ""), 2) | |
1132 end | |
1133 local font, _, flags = text:GetFont() | |
1134 text:SetFont(font, size, flags) | |
1135 end | |
1136 self:CheckWidth() | |
1137 end | |
1138 | |
1139 local function IsLoadOnDemand(plugin) | |
1140 return IsAddOnLoadOnDemand(folderNames[plugin] or "") | |
1141 end | |
1142 | |
1143 -- #NODOC | |
1144 -- this is used internally by FuBar. | |
1145 function FuBarPlugin:IsDisabled() | |
1146 return type(self.IsActive) == "function" and not self:IsActive() or false | |
1147 end | |
1148 | |
1149 function FuBarPlugin:OnEmbed(target) | |
1150 local folder = Rock.addonToFolder[target] | |
1151 if not folder then | |
1152 for i = 6, 3, -1 do | |
1153 folder = debugstack(i, 1, 0):match([[\AddOns\(.*)\]]) | |
1154 if folder then | |
1155 break | |
1156 end | |
1157 end | |
1158 end | |
1159 folderNames[target] = folder | |
1160 end | |
1161 | |
1162 local frame_OnClick, frame_OnDoubleClick, frame_OnMouseDown, frame_OnMouseUp, frame_OnReceiveDrag, frame_OnEnter, frame_OnLeave | |
1163 --[[--------------------------------------------------------------------------- | |
1164 Arguments: | |
1165 [optional] string - name of the frame | |
1166 Returns: | |
1167 frame - a frame with the basic scripts to be considered a plugin frame. | |
1168 Example: | |
1169 MyPlugin.frame = MyPlugin:CreateBasicPluginFrame("FuBar_MyPluginFrame") | |
1170 -----------------------------------------------------------------------------]] | |
1171 function FuBarPlugin:CreateBasicPluginFrame(name) | |
1172 local frame = CreateFrame("Button", name, UIParent) | |
1173 frame:SetFrameStrata("HIGH") | |
1174 frame:SetFrameLevel(7) | |
1175 frame:EnableMouse(true) | |
1176 frame:EnableMouseWheel(true) | |
1177 frame:SetMovable(true) | |
1178 frame:SetWidth(150) | |
1179 frame:SetHeight(24) | |
1180 frame:SetPoint("CENTER", UIParent, "CENTER") | |
1181 frame.self = self | |
1182 if not frame_OnEnter then | |
1183 function frame_OnEnter(this) | |
1184 local self = this.self | |
1185 local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip") | |
1186 if tooltipType == "GameTooltip" then | |
1187 GameTooltip:SetOwner(self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self], "ANCHOR_CURSOR") | |
1188 self:UpdateFuBarTooltip() | |
1189 end | |
1190 if type(self.OnFuBarEnter) == "function" then | |
1191 self:OnFuBarEnter() | |
1192 end | |
1193 end | |
1194 end | |
1195 frame:SetScript("OnEnter", frame_OnEnter) | |
1196 if not frame_OnLeave then | |
1197 function frame_OnLeave(this) | |
1198 local self = this.self | |
1199 if type(self.OnFuBarLeave) == "function" then | |
1200 self:OnFuBarLeave() | |
1201 end | |
1202 local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip") | |
1203 if tooltipType == "GameTooltip" and GameTooltip:IsOwned(self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self]) then | |
1204 GameTooltip:Hide() | |
1205 end | |
1206 end | |
1207 end | |
1208 frame:SetScript("OnLeave", frame_OnLeave) | |
1209 if not frame_OnClick then | |
1210 function frame_OnClick(this, button) | |
1211 local self = this.self | |
1212 if self:IsFuBarMinimapAttached() and this.dragged then return end | |
1213 if type(self.OnFuBarClick) == "function" then | |
1214 self:OnFuBarClick(button) | |
1215 end | |
1216 end | |
1217 end | |
1218 frame:SetScript("OnClick", frame_OnClick) | |
1219 if not frame_OnDoubleClick then | |
1220 function frame_OnDoubleClick(this, button) | |
1221 local self = this.self | |
1222 if type(self.OnFuBarDoubleClick) == "function" then | |
1223 self:OnFuBarDoubleClick(button) | |
1224 end | |
1225 end | |
1226 end | |
1227 frame:SetScript("OnDoubleClick", frame_OnDoubleClick) | |
1228 if not frame_OnMouseDown then | |
1229 function frame_OnMouseDown(this, button) | |
1230 local self = this.self | |
1231 if button == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then | |
1232 self:OpenMenu() | |
1233 return | |
1234 else | |
1235 if type(self.OnFuBarMouseDown) == "function" then | |
1236 self:OnFuBarMouseDown(button) | |
1237 end | |
1238 end | |
1239 end | |
1240 end | |
1241 frame:SetScript("OnMouseDown", frame_OnMouseDown) | |
1242 if not frame_OnMouseUp then | |
1243 function frame_OnMouseUp(this, button) | |
1244 local self = this.self | |
1245 if type(self.OnFuBarMouseUp) == "function" then | |
1246 self:OnFuBarMouseUp(button) | |
1247 end | |
1248 end | |
1249 end | |
1250 frame:SetScript("OnMouseUp", frame_OnMouseUp) | |
1251 if not frame_OnReceiveDrag then | |
1252 function frame_OnReceiveDrag(this) | |
1253 local self = this.self | |
1254 if (self:IsFuBarMinimapAttached() and not this.dragged) and type(self.OnReceiveDrag) == "function" then | |
1255 self:OnFuBarReceiveDrag() | |
1256 end | |
1257 end | |
1258 end | |
1259 frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag) | |
1260 return frame | |
1261 end | |
1262 | |
1263 local child_OnEnter, child_OnLeave, child_OnClick, child_OnDoubleClick, child_OnMouseDown, child_OnMouseUp, child_OnReceiveDrag | |
1264 --[[--------------------------------------------------------------------------- | |
1265 Arguments: | |
1266 string - type of the frame, e.g. "Frame", "Button", etc. | |
1267 [optional] string - name of the frame | |
1268 [optional] frame - parent frame | |
1269 Returns: | |
1270 frame - a child frame that can be manipulated and used | |
1271 Example: | |
1272 local child = self:CreatePluginChildFrame("Frame", nil, self.frame) | |
1273 -----------------------------------------------------------------------------]] | |
1274 function FuBarPlugin:CreatePluginChildFrame(frameType, name, parent) | |
1275 local child = CreateFrame(frameType, name, parent) | |
1276 if parent then | |
1277 child:SetFrameLevel(parent:GetFrameLevel() + 2) | |
1278 end | |
1279 child.self = self | |
1280 if not child_OnEnter then | |
1281 function child_OnEnter(this, ...) | |
1282 local self = this.self | |
1283 local frame = pluginToFrame[self] | |
1284 if frame:GetScript("OnEnter") then | |
1285 frame:GetScript("OnEnter")(frame, ...) | |
1286 end | |
1287 end | |
1288 end | |
1289 child:SetScript("OnEnter", child_OnEnter) | |
1290 if not child_OnLeave then | |
1291 function child_OnLeave(this, ...) | |
1292 local self = this.self | |
1293 local frame = pluginToFrame[self] | |
1294 if frame:GetScript("OnLeave") then | |
1295 frame:GetScript("OnLeave")(frame, ...) | |
1296 end | |
1297 end | |
1298 end | |
1299 child:SetScript("OnLeave", child_OnLeave) | |
1300 if child:HasScript("OnClick") then | |
1301 if not child_OnClick then | |
1302 function child_OnClick(this, ...) | |
1303 local self = this.self | |
1304 local frame = pluginToFrame[self] | |
1305 if frame:HasScript("OnClick") and frame:GetScript("OnClick") then | |
1306 frame:GetScript("OnClick")(frame, ...) | |
1307 end | |
1308 end | |
1309 end | |
1310 child:SetScript("OnClick", child_OnClick) | |
1311 end | |
1312 if child:HasScript("OnDoubleClick") then | |
1313 if not child_OnDoubleClick then | |
1314 function child_OnDoubleClick(this, ...) | |
1315 local self = this.self | |
1316 local frame = pluginToFrame[self] | |
1317 if frame:HasScript("OnDoubleClick") and frame:GetScript("OnDoubleClick") then | |
1318 frame:GetScript("OnDoubleClick")(frame, ...) | |
1319 end | |
1320 end | |
1321 end | |
1322 child:SetScript("OnDoubleClick", child_OnDoubleClick) | |
1323 end | |
1324 if not child_OnMouseDown then | |
1325 function child_OnMouseDown(this, ...) | |
1326 local self = this.self | |
1327 local frame = pluginToFrame[self] | |
1328 if frame:HasScript("OnMouseDown") and frame:GetScript("OnMouseDown") then | |
1329 frame:GetScript("OnMouseDown")(frame, ...) | |
1330 end | |
1331 end | |
1332 end | |
1333 child:SetScript("OnMouseDown", child_OnMouseDown) | |
1334 if not child_OnMouseUp then | |
1335 function child_OnMouseUp(this, ...) | |
1336 local self = this.self | |
1337 local frame = pluginToFrame[self] | |
1338 if frame:HasScript("OnMouseUp") and frame:GetScript("OnMouseUp") then | |
1339 frame:GetScript("OnMouseUp")(frame, ...) | |
1340 end | |
1341 end | |
1342 end | |
1343 child:SetScript("OnMouseUp", child_OnMouseUp) | |
1344 if not child_OnReceiveDrag then | |
1345 function child_OnReceiveDrag(this, ...) | |
1346 local self = this.self | |
1347 local frame = pluginToFrame[self] | |
1348 if frame:HasScript("OnReceiveDrag") and frame:GetScript("OnReceiveDrag") then | |
1349 frame:GetScript("OnReceiveDrag")(frame, ...) | |
1350 end | |
1351 end | |
1352 end | |
1353 child:SetScript("OnReceiveDrag", child_OnReceiveDrag) | |
1354 return child | |
1355 end | |
1356 precondition(FuBarPlugin, 'CreatePluginChildFrame', function(self, frameType, name, parent) | |
1357 if not pluginToFrame[self] then | |
1358 error(("%sYou must have self.frame declared in order to add child frames."):format(self.name and self.name .. ": " or ""), 3) | |
1359 end | |
1360 argCheck(frameType, 2, "string") | |
1361 end) | |
1362 | |
1363 --[[--------------------------------------------------------------------------- | |
1364 Notes: | |
1365 Opens the configuration menu associated with this plugin. | |
1366 Example: | |
1367 self:OpenMenu() | |
1368 -----------------------------------------------------------------------------]] | |
1369 function FuBarPlugin:OpenMenu(frame) | |
1370 if not frame then | |
1371 frame = self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self] | |
1372 end | |
1373 if not frame:IsVisible() then | |
1374 frame = UIParent | |
1375 end | |
1376 local configType = getPluginOption(self, 'configType', "LibRockConfig-1.0") | |
1377 if configType == "Dewdrop-2.0" then | |
1378 if not frame or not self:GetFrame() or Dewdrop20:IsOpen(frame) then | |
1379 Dewdrop20:Close() | |
1380 return | |
1381 end | |
1382 local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip") | |
1383 if tooltipType == "GameTooltip" then | |
1384 if GameTooltip:IsOwned(frame) then | |
1385 GameTooltip:Hide() | |
1386 end | |
1387 elseif tooltipType == "Custom" and type(self.CloseTooltip) == "function" then | |
1388 self:CloseTooltip() | |
1389 elseif tooltipType == "Tablet-2.0" and Tablet20 then | |
1390 Tablet20:Close() | |
1391 end | |
1392 | |
1393 if not Dewdrop20:IsRegistered(self:GetFrame()) then | |
1394 if type(self.OnMenuRequest) == "table" and (not self.OnMenuRequest.handler or self.OnMenuRequest.handler == self) and self.OnMenuRequest.type == "group" then | |
1395 Dewdrop20:InjectAceOptionsTable(self, self.OnMenuRequest) | |
1396 if self.OnMenuRequest.args and CheckFuBar() and not getPluginOption(self, 'independentProfile', false) then | |
1397 self.OnMenuRequest.args.profile = nil | |
1398 if self.OnMenuRequest.extraArgs then | |
1399 self.OnMenuRequest.extraArgs.profile = nil | |
1400 end | |
1401 end | |
1402 end | |
1403 Dewdrop20:Register(self:GetFrame(), | |
1404 'children', type(self.OnMenuRequest) == "table" and self.OnMenuRequest or function(level, value, valueN_1, valueN_2, valueN_3, valueN_4) | |
1405 if level == 1 then | |
1406 if not getPluginOption(self, 'hideMenuTitle', false) then | |
1407 Dewdrop20:AddLine( | |
1408 'text', self:GetTitle(), | |
1409 'isTitle', true | |
1410 ) | |
1411 end | |
1412 | |
1413 if self.OnMenuRequest then | |
1414 self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4) | |
1415 end | |
1416 | |
1417 if not getPluginOption(self, 'overrideMenu', false) then | |
1418 if self.MenuSettings and not getPluginOption(self, 'hideMenuTitle', false) then | |
1419 Dewdrop20:AddLine() | |
1420 end | |
1421 self:AddImpliedMenuOptions() | |
1422 end | |
1423 else | |
1424 if not getPluginOption(self, 'overrideMenu', false) and self:AddImpliedMenuOptions() then | |
1425 else | |
1426 if self.OnMenuRequest then | |
1427 self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4) | |
1428 end | |
1429 end | |
1430 end | |
1431 if level == 1 then | |
1432 Dewdrop20:AddLine( | |
1433 'text', CLOSE, | |
1434 'tooltipTitle', CLOSE, | |
1435 'tooltipText', CLOSE_DESC, | |
1436 'func', Dewdrop.Close, | |
1437 'arg1', Dewdrop | |
1438 ) | |
1439 end | |
1440 end, | |
1441 'point', function(frame) | |
1442 local x, y = frame:GetCenter() | |
1443 local leftRight | |
1444 if x < GetScreenWidth() / 2 then | |
1445 leftRight = "LEFT" | |
1446 else | |
1447 leftRight = "RIGHT" | |
1448 end | |
1449 if y < GetScreenHeight() / 2 then | |
1450 return "BOTTOM" .. leftRight, "TOP" .. leftRight | |
1451 else | |
1452 return "TOP" .. leftRight, "BOTTOM" .. leftRight | |
1453 end | |
1454 end, | |
1455 'dontHook', true | |
1456 ) | |
1457 end | |
1458 if frame == self:GetFrame() then | |
1459 Dewdrop20:Open(self:GetFrame()) | |
1460 elseif frame ~= UIParent then | |
1461 Dewdrop20:Open(frame, self:GetFrame()) | |
1462 else | |
1463 Dewdrop20:Open(frame, self:GetFrame(), 'cursorX', true, 'cursorY', true) | |
1464 end | |
1465 elseif configType == "LibRockConfig-1.0" then | |
1466 local RockConfig = Rock("LibRockConfig-1.0", false, true) | |
1467 if RockConfig then | |
1468 RockConfig.OpenConfigMenu(self) | |
1469 end | |
1470 else | |
1471 -- TODO: add more possibilities | |
1472 end | |
1473 end | |
1474 | |
1475 function FuBarPlugin.OnEmbedInitialize(FuBarPlugin, self) | |
1476 if not self.frame then | |
1477 local name = MAJOR_VERSION .. "_" .. self:GetTitle() .. "_" .. "Frame" | |
1478 local frame = _G[name] | |
1479 if not frame or not _G[name .. "Text"] or not _G[name .. "Icon"] then | |
1480 frame = FuBarPlugin.CreateBasicPluginFrame(self, name) | |
1481 | |
1482 local icon = frame:CreateTexture(name .. "Icon", "ARTWORK") | |
1483 frame.icon = icon | |
1484 icon:SetWidth(16) | |
1485 icon:SetHeight(16) | |
1486 icon:SetPoint("LEFT", frame, "LEFT") | |
1487 | |
1488 local text = frame:CreateFontString(name .. "Text", "ARTWORK") | |
1489 frame.text = text | |
1490 text:SetWidth(134) | |
1491 text:SetHeight(24) | |
1492 text:SetPoint("LEFT", icon, "RIGHT", 0, 1) | |
1493 text:SetFontObject(GameFontNormal) | |
1494 end | |
1495 pluginToFrame[self] = frame | |
1496 else | |
1497 pluginToFrame[self] = self.frame | |
1498 if not pluginToOptions[self] then | |
1499 pluginToOptions[self] = {} | |
1500 end | |
1501 pluginToOptions[self].userDefinedFrame = true | |
1502 end | |
1503 | |
1504 local frame = pluginToFrame[self] | |
1505 frame.plugin = self | |
1506 frame:SetParent(UIParent) | |
1507 frame:SetPoint("RIGHT", UIParent, "LEFT", -5, 0) | |
1508 frame:Hide() | |
1509 | |
1510 local iconPath = getPluginOption(self, 'iconPath', false) | |
1511 if iconPath then | |
1512 self:SetFuBarIcon(iconPath) | |
1513 end | |
1514 | |
1515 if CheckFuBar() then | |
1516 FuBar:RegisterPlugin(self) | |
1517 end | |
1518 end | |
1519 | |
1520 | |
1521 local CheckShow = function(self, panelId) | |
1522 if not pluginToFrame[self]:IsShown() and (not pluginToMinimapFrame[self] or not pluginToMinimapFrame[self]:IsShown()) then | |
1523 self:Show(panelId) | |
1524 end | |
1525 end | |
1526 | |
1527 local schedules = {} | |
1528 local f = CreateFrame("Frame") | |
1529 f:SetScript("OnUpdate", function(this) | |
1530 for i,v in ipairs(schedules) do | |
1531 local success, ret = pcall(unpack(v)) | |
1532 if not success then | |
1533 geterrorhandler()(ret) | |
1534 end | |
1535 schedules[i] = del(v) | |
1536 end | |
1537 f:Hide() | |
1538 end) | |
1539 | |
1540 local recheckPlugins | |
1541 local AceConsole | |
1542 function FuBarPlugin.OnEmbedEnable(FuBarPlugin, self, first) | |
1543 if not getPluginOption(self, 'userDefinedFrame', false) then | |
1544 local icon = pluginToFrame[self].icon | |
1545 if self:IsFuBarIconShown() then | |
1546 icon:Show() | |
1547 else | |
1548 icon:Hide() | |
1549 end | |
1550 end | |
1551 self:CheckWidth(true) | |
1552 | |
1553 if not getPluginOption(self, 'hideWithoutStandby', false) or (getLazyDatabaseValue(self) and not getLazyDatabaseValue(self, 'hidden')) then | |
1554 if not first then | |
1555 CheckShow(self, self.panelIdTmp) | |
1556 else | |
1557 schedules[#schedules+1] = newList(CheckShow, self, self.panelIdTmp) | |
1558 f:Show() | |
1559 end | |
1560 end | |
1561 | |
1562 local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip") | |
1563 if tooltipType == "Tablet-2.0" and not getPluginOption(self, 'cannotDetachTooltip', false) and getLazyDatabaseValue(self, 'detachedTooltip', 'detached') then | |
1564 schedules[#schedules+1] = newList(self.DetachFuBarTooltip, self) | |
1565 f:Show() | |
1566 end | |
1567 | |
1568 if IsLoadOnDemand(self) and CheckFuBar() then | |
1569 if not FuBar.db.profile.loadOnDemand then | |
1570 FuBar.db.profile.loadOnDemand = {} | |
1571 end | |
1572 if not FuBar.db.profile.loadOnDemand[folderNames[self]] then | |
1573 FuBar.db.profile.loadOnDemand[folderNames[self]] = {} | |
1574 end | |
1575 FuBar.db.profile.loadOnDemand[folderNames[self]].disabled = nil | |
1576 end | |
1577 --[[ | |
1578 if CheckFuBar() and AceLibrary:HasInstance("AceConsole-2.0") then | |
1579 if not recheckPlugins then | |
1580 if not AceConsole then | |
1581 AceConsole = AceLibrary("AceConsole-2.0") | |
1582 end | |
1583 recheckPlugins = function() | |
1584 for k,v in pairs(AceConsole.registry) do | |
1585 if type(v) == "table" and v.args and AceOO.inherits(v.handler, FuBarPlugin) and not v.handler.independentProfile then | |
1586 v.args.profile = nil | |
1587 end | |
1588 end | |
1589 end | |
1590 end | |
1591 FuBarPlugin:ScheduleEvent("FuBarPlugin-recheckPlugins", recheckPlugins, 0) | |
1592 end | |
1593 ]] | |
1594 end | |
1595 | |
1596 function FuBarPlugin.OnEmbedDisable(FuBarPlugin, self) | |
1597 self:Hide(false) | |
1598 | |
1599 if IsLoadOnDemand(self) and CheckFuBar() then | |
1600 if not FuBar.db.profile.loadOnDemand then | |
1601 FuBar.db.profile.loadOnDemand = {} | |
1602 end | |
1603 if not FuBar.db.profile.loadOnDemand[folderNames[self]] then | |
1604 FuBar.db.profile.loadOnDemand[folderNames[self]] = {} | |
1605 end | |
1606 FuBar.db.profile.loadOnDemand[folderNames[self]].disabled = true | |
1607 end | |
1608 end | |
1609 | |
1610 function FuBarPlugin.OnEmbedProfileEnable(FuBarPlugin, self) | |
1611 self:UpdateFuBarPlugin() | |
1612 if getLazyDatabaseValue(self) then | |
1613 if not getLazyDatabaseValue(self, 'detachedTooltip') then | |
1614 setLazyDatabaseValue(self, {}, 'detachedTooltip') | |
1615 end | |
1616 local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip") | |
1617 if tooltipType == "Tablet-2.0" and Tablet20 then | |
1618 if Tablet20.registry[pluginToFrame[self]] then | |
1619 Tablet20:UpdateDetachedData(pluginToFrame[self], getLazyDatabaseValue(self, 'detachedTooltip')) | |
1620 else | |
1621 RegisterTablet20(self) | |
1622 end | |
1623 end | |
1624 if MinimapContainer:HasPlugin(self) then | |
1625 MinimapContainer:ReadjustLocation(self) | |
1626 end | |
1627 end | |
1628 end | |
1629 | |
1630 -- #NODOC | |
1631 function FuBarPlugin.GetEmbedRockConfigOptions(FuBarPlugin, self) | |
1632 return 'icon', { | |
1633 type = 'boolean', | |
1634 name = SHOW_FUBAR_ICON, | |
1635 desc = SHOW_FUBAR_ICON_DESC, | |
1636 set = "ToggleFuBarIconShown", | |
1637 get = "IsFuBarIconShown", | |
1638 hidden = function() | |
1639 return not getPluginOption(self, 'iconPath', false) or getPluginOption(self, 'hasNoText', false) or self:IsDisabled() or self:IsFuBarMinimapAttached() or not getLazyDatabaseValue(self) | |
1640 end, | |
1641 order = -13.7, | |
1642 handler = self, | |
1643 }, 'text', { | |
1644 type = 'boolean', | |
1645 name = SHOW_FUBAR_TEXT, | |
1646 desc = SHOW_FUBAR_TEXT_DESC, | |
1647 set = "ToggleFuBarTextShown", | |
1648 get = "IsFuBarTextShown", | |
1649 hidden = function() | |
1650 return getPluginOption(self, 'cannotHideText', false) or not getPluginOption(self, 'iconPath', false) or getPluginOption(self, 'hasNoText') or self:IsDisabled() or self:IsFuBarMinimapAttached() or not getLazyDatabaseValue(self) | |
1651 end, | |
1652 order = -13.6, | |
1653 handler = self, | |
1654 }, 'colorText', { | |
1655 type = 'boolean', | |
1656 name = SHOW_COLORED_FUBAR_TEXT, | |
1657 desc = SHOW_COLORED_FUBAR_TEXT_DESC, | |
1658 set = "ToggleFuBarTextColored", | |
1659 get = "IsFuBarTextColored", | |
1660 hidden = function() | |
1661 return getPluginOption(self, 'userDefinedFrame', false) or getPluginOption(self, 'hasNoText', false) or getPluginOption(self, 'hasNoColor', false) or self:IsDisabled() or self:IsFuBarMinimapAttached() or not getLazyDatabaseValue(self) | |
1662 end, | |
1663 order = -13.5, | |
1664 handler = self, | |
1665 }, 'detachTooltip', { | |
1666 type = 'boolean', | |
1667 name = DETACH_FUBAR_TOOLTIP, | |
1668 desc = DETACH_FUBAR_TOOLTIP_DESC, | |
1669 get = "IsFuBarTooltipDetached", | |
1670 set = "ToggleFuBarTooltipDetached", | |
1671 hidden = function() | |
1672 return not Tablet20 or getPluginOption(self, 'tooltipType', "GameTooltip") ~= "Tablet-2.0" or self:IsDisabled() | |
1673 end, | |
1674 order = -13.4, | |
1675 handler = self, | |
1676 }, 'lockTooltip', { | |
1677 type = 'boolean', | |
1678 name = LOCK_FUBAR_TOOLTIP, | |
1679 desc = LOCK_FUBAR_TOOLTIP_DESC, | |
1680 get = function() | |
1681 return Tablet20:IsLocked(pluginToFrame[self]) | |
1682 end, | |
1683 set = function() | |
1684 return Tablet20:ToggleLocked(pluginToFrame[self]) | |
1685 end, | |
1686 disabled = function() | |
1687 return not self:IsFuBarTooltipDetached() | |
1688 end, | |
1689 hidden = function() | |
1690 return not Tablet20 or getPluginOption(self, 'tooltipType', "GameTooltip") ~= "Tablet-2.0" or getPluginOption(self, 'cannotDetachTooltip', false) or self:IsDisabled() | |
1691 end, | |
1692 order = -13.3, | |
1693 handler = self, | |
1694 }, 'position', { | |
1695 type = 'choice', | |
1696 name = POSITION_ON_FUBAR, | |
1697 desc = POSITION_ON_FUBAR_DESC, | |
1698 choices = { | |
1699 LEFT = POSITION_LEFT, | |
1700 CENTER = POSITION_CENTER, | |
1701 RIGHT = POSITION_RIGHT | |
1702 }, | |
1703 choiceSort = { | |
1704 "LEFT", | |
1705 "CENTER", | |
1706 "RIGHT", | |
1707 }, | |
1708 get = function() | |
1709 return self:GetPanel() and self:GetPanel():GetPluginSide(self) | |
1710 end, | |
1711 set = function(value) | |
1712 if self:GetPanel() then | |
1713 self:GetPanel():SetPluginSide(self, value) | |
1714 end | |
1715 end, | |
1716 hidden = function() | |
1717 return self:IsFuBarMinimapAttached() or self:IsDisabled() or not pluginToPanel[self] | |
1718 end, | |
1719 order = -13.2, | |
1720 handler = self, | |
1721 }, 'minimapAttach', { | |
1722 type = 'boolean', | |
1723 name = ATTACH_PLUGIN_TO_MINIMAP, | |
1724 desc = ATTACH_PLUGIN_TO_MINIMAP_DESC, | |
1725 get = "IsFuBarMinimapAttached", | |
1726 set = "ToggleFuBarMinimapAttached", | |
1727 hidden = function() | |
1728 return (getPluginOption(self, 'cannotAttachToMinimap', false) and not self:IsFuBarMinimapAttached()) or not CheckFuBar() or self:IsDisabled() | |
1729 end, | |
1730 order = -13.1, | |
1731 handler = self, | |
1732 }, 'hide', { | |
1733 type = 'boolean', | |
1734 name = function() | |
1735 if self:IsFuBarMinimapAttached() then | |
1736 return HIDE_MINIMAP_BUTTON | |
1737 else | |
1738 return HIDE_FUBAR_PLUGIN | |
1739 end | |
1740 end, | |
1741 desc = HIDE_FUBAR_PLUGIN_DESC, | |
1742 get = function() | |
1743 return not pluginToFrame[self]:IsShown() and (not pluginToMinimapFrame[self] or not pluginToMinimapFrame[self]:IsShown()) | |
1744 end, | |
1745 set = function(value) | |
1746 if not value then | |
1747 self:Show() | |
1748 else | |
1749 self:Hide() | |
1750 end | |
1751 end, | |
1752 hidden = function() | |
1753 return not getPluginOption(self, 'hideWithoutStandby', false) or self:IsDisabled() | |
1754 end, | |
1755 order = -13, | |
1756 handler = self, | |
1757 } | |
1758 end | |
1759 | |
1760 local plugins = MinimapContainer.plugins or {} | |
1761 for k in pairs(MinimapContainer) do | |
1762 MinimapContainer[k] = nil | |
1763 end | |
1764 MinimapContainer.plugins = plugins | |
1765 | |
1766 local minimap_OnMouseDown, minimap_OnMouseUp | |
1767 function MinimapContainer:AddPlugin(plugin) | |
1768 if CheckFuBar() and FuBar:IsChangingProfile() then | |
1769 return | |
1770 end | |
1771 if pluginToPanel[plugin] then | |
1772 pluginToPanel[plugin]:RemovePlugin(plugin) | |
1773 end | |
1774 pluginToPanel[plugin] = self | |
1775 if not pluginToMinimapFrame[plugin] then | |
1776 local frame = CreateFrame("Button", pluginToFrame[plugin]:GetName() .. "MinimapButton", Minimap) | |
1777 pluginToMinimapFrame[plugin] = frame | |
1778 plugin.minimapFrame = frame | |
1779 frame.plugin = plugin | |
1780 frame:SetWidth(31) | |
1781 frame:SetHeight(31) | |
1782 frame:SetFrameStrata("BACKGROUND") | |
1783 frame:SetFrameLevel(4) | |
1784 frame:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight") | |
1785 local icon = frame:CreateTexture(frame:GetName() .. "Icon", "BACKGROUND") | |
1786 plugin.minimapIcon = icon | |
1787 local path = plugin:GetFuBarIcon() or (pluginToFrame[plugin].icon and pluginToFrame[plugin].icon:GetTexture()) or "Interface\\Icons\\INV_Misc_QuestionMark" | |
1788 icon:SetTexture(path) | |
1789 if path:sub(1, 16) == "Interface\\Icons\\" then | |
1790 icon:SetTexCoord(0.07, 0.93, 0.07, 0.93) | |
1791 else | |
1792 icon:SetTexCoord(0, 1, 0, 1) | |
1793 end | |
1794 icon:SetWidth(20) | |
1795 icon:SetHeight(20) | |
1796 icon:SetPoint("TOPLEFT", frame, "TOPLEFT", 7, -5) | |
1797 local overlay = frame:CreateTexture(frame:GetName() .. "Overlay","OVERLAY") | |
1798 overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder") | |
1799 overlay:SetWidth(53) | |
1800 overlay:SetHeight(53) | |
1801 overlay:SetPoint("TOPLEFT",frame,"TOPLEFT") | |
1802 frame:EnableMouse(true) | |
1803 frame:RegisterForClicks("LeftButtonUp") | |
1804 | |
1805 frame.self = plugin | |
1806 if not frame_OnEnter then | |
1807 function frame_OnEnter(this) | |
1808 if type(this.self.OnFuBarEnter) == "function" then | |
1809 this.self:OnFuBarEnter() | |
1810 end | |
1811 end | |
1812 end | |
1813 frame:SetScript("OnEnter", frame_OnEnter) | |
1814 if not frame_OnLeave then | |
1815 function frame_OnLeave(this) | |
1816 if type(this.self.OnFuBarLeave) == "function" then | |
1817 this.self:OnFuBarLeave() | |
1818 end | |
1819 end | |
1820 end | |
1821 frame:SetScript("OnLeave", frame_OnLeave) | |
1822 if not frame_OnClick then | |
1823 function frame_OnClick(this, arg1) | |
1824 if this.self:IsMinimapAttached() and this.dragged then return end | |
1825 if type(this.self.OnFuBarClick) == "function" then | |
1826 this.self:OnFuBarClick(arg1) | |
1827 end | |
1828 end | |
1829 end | |
1830 frame:SetScript("OnClick", frame_OnClick) | |
1831 if not frame_OnDoubleClick then | |
1832 function frame_OnDoubleClick(this, arg1) | |
1833 if type(this.self.OnFuBarDoubleClick) == "function" then | |
1834 this.self:OnFuBarDoubleClick(arg1) | |
1835 end | |
1836 end | |
1837 end | |
1838 frame:SetScript("OnDoubleClick", frame_OnDoubleClick) | |
1839 if not frame_OnReceiveDrag then | |
1840 function frame_OnReceiveDrag(this) | |
1841 if this.self:IsMinimapAttached() and this.dragged then return end | |
1842 if type(this.self.OnFuBarReceiveDrag) == "function" then | |
1843 this.self:OnFuBarReceiveDrag() | |
1844 end | |
1845 end | |
1846 end | |
1847 frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag) | |
1848 if not minimap_OnMouseDown then | |
1849 function minimap_OnMouseDown(this, arg1) | |
1850 this.dragged = false | |
1851 if arg1 == "LeftButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then | |
1852 HideDropDownMenu(1) | |
1853 if type(this.self.OnFuBarMouseDown) == "function" then | |
1854 this.self:OnFuBarMouseDown(arg1) | |
1855 end | |
1856 elseif arg1 == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then | |
1857 this.self:OpenMenu(this) | |
1858 else | |
1859 HideDropDownMenu(1) | |
1860 if type(this.self.OnFuBarMouseDown) == "function" then | |
1861 this.self:OnFuBarMouseDown(arg1) | |
1862 end | |
1863 end | |
1864 if this.self.OnFuBarClick or this.self.OnFuBarMouseDown or this.self.OnFuBarMouseUp or this.self.OnFuBarDoubleClick then | |
1865 if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then | |
1866 this.self.minimapIcon:SetTexCoord(0.14, 0.86, 0.14, 0.86) | |
1867 else | |
1868 this.self.minimapIcon:SetTexCoord(0.1, 0.9, 0.1, 0.9) | |
1869 end | |
1870 end | |
1871 end | |
1872 end | |
1873 frame:SetScript("OnMouseDown", minimap_OnMouseDown) | |
1874 if not minimap_OnMouseUp then | |
1875 function minimap_OnMouseUp(this, arg1) | |
1876 if not this.dragged and type(this.self.OnFuBarMouseUp) == "function" then | |
1877 this.self:OnFuBarMouseUp(arg1) | |
1878 end | |
1879 if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then | |
1880 this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) | |
1881 else | |
1882 this.self.minimapIcon:SetTexCoord(0, 1, 0, 1) | |
1883 end | |
1884 end | |
1885 end | |
1886 frame:SetScript("OnMouseUp", minimap_OnMouseUp) | |
1887 frame:RegisterForDrag("LeftButton") | |
1888 frame:SetScript("OnDragStart", self.OnDragStart) | |
1889 frame:SetScript("OnDragStop", self.OnDragStop) | |
1890 | |
1891 if getPluginOption(plugin, 'tooltipType', "GameTooltip") == "Tablet-2.0" then | |
1892 -- Note that we have to do this after :SetScript("OnEnter"), etc, | |
1893 -- so that Tablet-2.0 can override it properly. | |
1894 RegisterTablet20(plugin) | |
1895 Tablet20:Register(frame, pluginToFrame[plugin]) | |
1896 end | |
1897 end | |
1898 pluginToFrame[plugin]:Hide() | |
1899 pluginToMinimapFrame[plugin]:Show() | |
1900 self:ReadjustLocation(plugin) | |
1901 table.insert(self.plugins, plugin) | |
1902 local exists = false | |
1903 return true | |
1904 end | |
1905 | |
1906 function MinimapContainer:RemovePlugin(index) | |
1907 if CheckFuBar() and FuBar:IsChangingProfile() then | |
1908 return | |
1909 end | |
1910 if type(index) == "table" then | |
1911 index = self:IndexOfPlugin(index) | |
1912 if not index then | |
1913 return | |
1914 end | |
1915 end | |
1916 local t = self.plugins | |
1917 local plugin = t[index] | |
1918 assert(pluginToPanel[plugin] == self, "Plugin has improper panel field") | |
1919 plugin:SetPanel(nil) | |
1920 table.remove(t, index) | |
1921 return true | |
1922 end | |
1923 | |
1924 function MinimapContainer:ReadjustLocation(plugin) | |
1925 local frame = pluginToMinimapFrame[plugin] | |
1926 if plugin.db and plugin.db.profile.minimapPositionWild then | |
1927 frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.db.profile.minimapPositionX, plugin.db.profile.minimapPositionY) | |
1928 elseif not plugin.db and plugin.minimapPositionWild then | |
1929 frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.minimapPositionX, plugin.minimapPositionY) | |
1930 else | |
1931 local position | |
1932 if plugin.db then | |
1933 position = plugin.db.profile.minimapPosition or getPluginOption(plugin, 'defaultMinimapPosition', nil) or math.random(1, 360) | |
1934 else | |
1935 position = plugin.minimapPosition or getPluginOption(plugin, 'defaultMinimapPosition', nil) or math.random(1, 360) | |
1936 end | |
1937 local angle = math.rad(position or 0) | |
1938 local x,y | |
1939 local minimapShape = GetMinimapShape and GetMinimapShape() or "ROUND" | |
1940 local cos = math.cos(angle) | |
1941 local sin = math.sin(angle) | |
1942 | |
1943 local round = true | |
1944 if minimapShape == "ROUND" then | |
1945 -- do nothing | |
1946 elseif minimapShape == "SQUARE" then | |
1947 round = false | |
1948 elseif minimapShape == "CORNER-TOPRIGHT" then | |
1949 if cos < 0 or sin < 0 then | |
1950 round = false | |
1951 end | |
1952 elseif minimapShape == "CORNER-TOPLEFT" then | |
1953 if cos > 0 or sin < 0 then | |
1954 round = false | |
1955 end | |
1956 elseif minimapShape == "CORNER-BOTTOMRIGHT" then | |
1957 if cos < 0 or sin > 0 then | |
1958 round = false | |
1959 end | |
1960 elseif minimapShape == "CORNER-BOTTOMLEFT" then | |
1961 if cos > 0 or sin > 0 then | |
1962 round = false | |
1963 end | |
1964 elseif minimapShape == "SIDE-LEFT" then | |
1965 if cos > 0 then | |
1966 round = false | |
1967 end | |
1968 elseif minimapShape == "SIDE-RIGHT" then | |
1969 if cos < 0 then | |
1970 round = false | |
1971 end | |
1972 elseif minimapShape == "SIDE-TOP" then | |
1973 if sin < 0 then | |
1974 round = false | |
1975 end | |
1976 elseif minimapShape == "SIDE-BOTTOM" then | |
1977 if sin > 0 then | |
1978 round = false | |
1979 end | |
1980 elseif minimapShape == "TRICORNER-TOPRIGHT" then | |
1981 if cos < 0 and sin < 0 then | |
1982 round = false | |
1983 end | |
1984 elseif minimapShape == "TRICORNER-TOPLEFT" then | |
1985 if cos > 0 and sin < 0 then | |
1986 round = false | |
1987 end | |
1988 elseif minimapShape == "TRICORNER-BOTTOMRIGHT" then | |
1989 if cos < 0 and sin > 0 then | |
1990 round = false | |
1991 end | |
1992 elseif minimapShape == "TRICORNER-BOTTOMLEFT" then | |
1993 if cos > 0 and sin > 0 then | |
1994 round = false | |
1995 end | |
1996 end | |
1997 | |
1998 if round then | |
1999 x = cos * 80 | |
2000 y = sin * 80 | |
2001 else | |
2002 x = 80 * 2^0.5 * cos | |
2003 y = 80 * 2^0.5 * sin | |
2004 if x < -80 then | |
2005 x = -80 | |
2006 elseif x > 80 then | |
2007 x = 80 | |
2008 end | |
2009 if y < -80 then | |
2010 y = -80 | |
2011 elseif y > 80 then | |
2012 y = 80 | |
2013 end | |
2014 end | |
2015 frame:SetPoint("CENTER", Minimap, "CENTER", x, y) | |
2016 end | |
2017 end | |
2018 | |
2019 function MinimapContainer:GetPlugin(index) | |
2020 return self.plugins[index] | |
2021 end | |
2022 | |
2023 function MinimapContainer:GetNumPlugins() | |
2024 return #self.plugins | |
2025 end | |
2026 | |
2027 function MinimapContainer:IndexOfPlugin(plugin) | |
2028 for i,p in ipairs(self.plugins) do | |
2029 if p == plugin then | |
2030 return i, "MINIMAP" | |
2031 end | |
2032 end | |
2033 end | |
2034 | |
2035 function MinimapContainer:HasPlugin(plugin) | |
2036 return self:IndexOfPlugin(plugin) ~= nil | |
2037 end | |
2038 | |
2039 function MinimapContainer:GetPluginSide(plugin) | |
2040 local index = self:IndexOfPlugin(plugin) | |
2041 assert(index, "Plugin not in panel") | |
2042 return "MINIMAP" | |
2043 end | |
2044 | |
2045 function MinimapContainer.OnDragStart(this) | |
2046 this.dragged = true | |
2047 this:LockHighlight() | |
2048 this:SetScript("OnUpdate", MinimapContainer.OnUpdate) | |
2049 if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then | |
2050 this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) | |
2051 else | |
2052 this.self.minimapIcon:SetTexCoord(0, 1, 0, 1) | |
2053 end | |
2054 end | |
2055 | |
2056 function MinimapContainer.OnDragStop(this) | |
2057 this:SetScript("OnUpdate", nil) | |
2058 this:UnlockHighlight() | |
2059 end | |
2060 | |
2061 function MinimapContainer.OnUpdate(this, elapsed) | |
2062 if not IsAltKeyDown() then | |
2063 local mx, my = Minimap:GetCenter() | |
2064 local px, py = GetCursorPosition() | |
2065 local scale = UIParent:GetEffectiveScale() | |
2066 px, py = px / scale, py / scale | |
2067 local position = math.deg(math.atan2(py - my, px - mx)) | |
2068 if position <= 0 then | |
2069 position = position + 360 | |
2070 elseif position > 360 then | |
2071 position = position - 360 | |
2072 end | |
2073 if this.self.db then | |
2074 this.self.db.profile.minimapPosition = position | |
2075 this.self.db.profile.minimapPositionX = nil | |
2076 this.self.db.profile.minimapPositionY = nil | |
2077 this.self.db.profile.minimapPositionWild = nil | |
2078 else | |
2079 this.self.minimapPosition = position | |
2080 this.self.minimapPositionX = nil | |
2081 this.self.minimapPositionY = nil | |
2082 this.self.minimapPositionWild = nil | |
2083 end | |
2084 else | |
2085 local px, py = GetCursorPosition() | |
2086 local scale = UIParent:GetEffectiveScale() | |
2087 px, py = px / scale, py / scale | |
2088 if this.self.db then | |
2089 this.self.db.profile.minimapPositionX = px | |
2090 this.self.db.profile.minimapPositionY = py | |
2091 this.self.db.profile.minimapPosition = nil | |
2092 this.self.db.profile.minimapPositionWild = true | |
2093 else | |
2094 this.self.minimapPositionX = px | |
2095 this.self.minimapPositionY = py | |
2096 this.self.minimapPosition = nil | |
2097 this.self.minimapPositionWild = true | |
2098 end | |
2099 end | |
2100 MinimapContainer:ReadjustLocation(this.self) | |
2101 end | |
2102 | |
2103 FuBarPlugin:SetExportedMethods( | |
2104 "SetFuBarOption", | |
2105 "GetTitle", | |
2106 "GetName", | |
2107 "GetCategory", | |
2108 "SetFontSize", | |
2109 "GetFrame", | |
2110 "Show", | |
2111 "Hide", | |
2112 "GetPanel", | |
2113 "IsFuBarTextColored", | |
2114 "ToggleFuBarTextColored", | |
2115 "IsFuBarMinimapAttached", | |
2116 "ToggleFuBarMinimapAttached", | |
2117 "UpdateFuBarPlugin", | |
2118 "UpdateFuBarText", | |
2119 "UpdateFuBarTooltip", | |
2120 "SetFuBarIcon", | |
2121 "GetFuBarIcon", | |
2122 "CheckWidth", | |
2123 "SetFuBarText", | |
2124 "GetFuBarText", | |
2125 "IsFuBarIconShown", | |
2126 "ToggleFuBarIconShown", | |
2127 "ShowFuBarIcon", | |
2128 "HideFuBarIcon", | |
2129 "IsFuBarTextShown", | |
2130 "ToggleFuBarTextShown", | |
2131 "ShowFuBarText", | |
2132 "HideFuBarText", | |
2133 "IsFuBarTooltipDetached", | |
2134 "ToggleFuBarTooltipDetached", | |
2135 "DetachFuBarTooltip", | |
2136 "ReattachFuBarTooltip", | |
2137 "GetDefaultPosition", | |
2138 "SetPanel", | |
2139 "IsDisabled", | |
2140 "CreateBasicPluginFrame", | |
2141 "CreatePluginChildFrame", | |
2142 "OpenMenu" | |
2143 ) | |
2144 | |
2145 Rock:FinalizeLibrary(MAJOR_VERSION) |