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