From 9b69b7c2fb4a63fc47f984bb26e7250f0e596156 Mon Sep 17 00:00:00 2001 From: James McCaughey Date: Thu, 29 Aug 2013 11:34:48 -0500 Subject: [PATCH] v2.1.1 --- Changelog.txt | 397 ++++++ Core.lua | 1009 +++++++++++++++ EquippedItemLevelTooltip.toc | 25 + Libs/AceAddon-3.0/AceAddon-3.0.lua | 659 ++++++++++ Libs/AceAddon-3.0/AceAddon-3.0.xml | 4 + Libs/AceComm-3.0/AceComm-3.0.lua | 382 ++++++ Libs/AceComm-3.0/AceComm-3.0.xml | 5 + Libs/AceComm-3.0/ChatThrottleLib.lua | 510 ++++++++ Libs/AceConsole-3.0/AceConsole-3.0.lua | 250 ++++ Libs/AceConsole-3.0/AceConsole-3.0.xml | 4 + Libs/AceDB-3.0/AceDB-3.0.lua | 733 +++++++++++ Libs/AceDB-3.0/AceDB-3.0.xml | 4 + Libs/AceEvent-3.0/AceEvent-3.0.lua | 126 ++ Libs/AceEvent-3.0/AceEvent-3.0.xml | 4 + Libs/AceGUI-3.0/AceGUI-3.0.lua | 805 ++++++++++++ Libs/AceGUI-3.0/AceGUI-3.0.xml | 28 + .../widgets/AceGUIContainer-BlizOptionsGroup.lua | 133 ++ .../widgets/AceGUIContainer-DropDownGroup.lua | 157 +++ Libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua | 311 +++++ .../widgets/AceGUIContainer-InlineGroup.lua | 102 ++ .../widgets/AceGUIContainer-ScrollFrame.lua | 204 +++ .../widgets/AceGUIContainer-SimpleGroup.lua | 69 + .../widgets/AceGUIContainer-TabGroup.lua | 350 ++++++ .../widgets/AceGUIContainer-TreeGroup.lua | 707 +++++++++++ Libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua | 331 +++++ Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua | 98 ++ Libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua | 295 +++++ .../widgets/AceGUIWidget-ColorPicker.lua | 186 +++ .../widgets/AceGUIWidget-DropDown-Items.lua | 471 +++++++ Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua | 717 +++++++++++ Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua | 256 ++++ Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua | 78 ++ Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua | 144 +++ .../widgets/AceGUIWidget-InteractiveLabel.lua | 101 ++ .../AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua | 239 ++++ Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua | 166 +++ .../widgets/AceGUIWidget-MultiLineEditBox.lua | 368 ++++++ Libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua | 281 +++++ Libs/AceHook-3.0/AceHook-3.0.lua | 514 ++++++++ Libs/AceHook-3.0/AceHook-3.0.xml | 4 + Libs/AceSerializer-3.0/AceSerializer-3.0.lua | 283 +++++ Libs/AceSerializer-3.0/AceSerializer-3.0.xml | 4 + Libs/AceTimer-3.0/AceTimer-3.0.lua | 475 +++++++ Libs/AceTimer-3.0/AceTimer-3.0.xml | 4 + Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua | 240 ++++ Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml | 4 + Libs/LibQTip-1.0/LibQTip-1.0.lua | 1329 ++++++++++++++++++++ Libs/LibStub/LibStub.lua | 30 + .../Changelog-libdatabroker-1-1-v1.1.4.txt | 33 + Libs/libdatabroker-1-1/LibDataBroker-1.1.lua | 90 ++ Libs/libdatabroker-1-1/README.textile | 13 + 51 files changed, 13732 insertions(+) create mode 100644 Changelog.txt create mode 100644 Core.lua create mode 100644 EquippedItemLevelTooltip.toc create mode 100644 Libs/AceAddon-3.0/AceAddon-3.0.lua create mode 100644 Libs/AceAddon-3.0/AceAddon-3.0.xml create mode 100644 Libs/AceComm-3.0/AceComm-3.0.lua create mode 100644 Libs/AceComm-3.0/AceComm-3.0.xml create mode 100644 Libs/AceComm-3.0/ChatThrottleLib.lua create mode 100644 Libs/AceConsole-3.0/AceConsole-3.0.lua create mode 100644 Libs/AceConsole-3.0/AceConsole-3.0.xml create mode 100644 Libs/AceDB-3.0/AceDB-3.0.lua create mode 100644 Libs/AceDB-3.0/AceDB-3.0.xml create mode 100644 Libs/AceEvent-3.0/AceEvent-3.0.lua create mode 100644 Libs/AceEvent-3.0/AceEvent-3.0.xml create mode 100644 Libs/AceGUI-3.0/AceGUI-3.0.lua create mode 100644 Libs/AceGUI-3.0/AceGUI-3.0.xml create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua create mode 100644 Libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua create mode 100644 Libs/AceHook-3.0/AceHook-3.0.lua create mode 100644 Libs/AceHook-3.0/AceHook-3.0.xml create mode 100644 Libs/AceSerializer-3.0/AceSerializer-3.0.lua create mode 100644 Libs/AceSerializer-3.0/AceSerializer-3.0.xml create mode 100644 Libs/AceTimer-3.0/AceTimer-3.0.lua create mode 100644 Libs/AceTimer-3.0/AceTimer-3.0.xml create mode 100644 Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua create mode 100644 Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml create mode 100644 Libs/LibQTip-1.0/LibQTip-1.0.lua create mode 100644 Libs/LibStub/LibStub.lua create mode 100644 Libs/libdatabroker-1-1/Changelog-libdatabroker-1-1-v1.1.4.txt create mode 100644 Libs/libdatabroker-1-1/LibDataBroker-1.1.lua create mode 100644 Libs/libdatabroker-1-1/README.textile diff --git a/Changelog.txt b/Changelog.txt new file mode 100644 index 0000000..f381637 --- /dev/null +++ b/Changelog.txt @@ -0,0 +1,397 @@ +----------------------------------------------------------------------------- + Version 2.1.1 +----------------------------------------------------------------------------- + + * Updated TOC for 5.3. + + * Added preliminary support for a possible solution to the problem of + detecting item upgrades. Thanks to Cyna on wowinterface.com for + providing a link to a forum post with the work-around. + +----------------------------------------------------------------------------- + Version 2.1.0 +----------------------------------------------------------------------------- + + * Did away with the options in the slash command and added a simple GUI + interface for configuration which is accessible via '/eailt' slash + command. + + * Removed unused libraries from the Libs directory. + + * Fixed another small conflict with TipTac when the items list is not + displayed. + +----------------------------------------------------------------------------- + Version 2.0.9 +----------------------------------------------------------------------------- + + * Refined the inspect function(s). + + * Added addon.InspectDelay to control how often an inspect request can + be sent. Essentially this controls the throttling of NotifyInspect. + + * Fixed a conflict with another tooltip addon. + + * Added /eailt slash command to configure addon settings in-game. + Variables no longer available at the top of the .lua file for + configuration. + +----------------------------------------------------------------------------- + Version 2.0.8 +----------------------------------------------------------------------------- + + * Fixed a problem with attempting to check specialization on characters + below level 10. + + * Fixed tooltip sizing issues with the default GameTooltip (also + compatible with TipTac) so information should no longer appear + outside of the tooltip or overlap other information. + +----------------------------------------------------------------------------- + Version 2.0.7 +----------------------------------------------------------------------------- + + * Fixed a problem that was causing the tooltip to become jumpy and not + show all information within the constraints of the tooltip at first. + +----------------------------------------------------------------------------- + Version 2.0.6 +----------------------------------------------------------------------------- + + * Specialization replaced Talents in tooltip. Point distribution will + not be shown, but the particular Specialization will be shown. + + * LibQTip-1.0 embedded to provide a better tooltip for the LDB plugin. + + * Specialization added to the LDB plugin tooltip. + +----------------------------------------------------------------------------- + Version 2.0.5 +----------------------------------------------------------------------------- + + * Discovered and fixed various miscellaneous error messages. + + * Added compatibility for beta and in-turn for the upcoming expansion's + API changes. + + * Talent info will no longer be displayed in tooltip as of MoP. The + talent setup would require showing a line for each chosen talent as + there are no longer distinct trees. + + * Hopefully removed error spam when in arenas/BGs. + +----------------------------------------------------------------------------- + Version 2.0.4 +----------------------------------------------------------------------------- + + * Fixed an error on login. + +----------------------------------------------------------------------------- + Version 2.0.3 +----------------------------------------------------------------------------- + + * Colorized item names in tooltip. + + * Added AceComm and AceSerializer libraries for addon communication + to be alerted by other users of the addon on new versions and + share item information with raid/party members without scanning + them. + + * Resorted the items in tooltip so they stay in a static order and + and added showing empty/not scanned slots (not scanned are the + ones blizzard has not given us information on yet). + + * Added table pruning so database does not exceed 50 records. + + * Added talents to tooltip (can be toggled with lua variable near + top of Core.lua file). + +----------------------------------------------------------------------------- + Version 2.0.2 +----------------------------------------------------------------------------- + + * Found some timer problems and disabled those timers + for now. + +----------------------------------------------------------------------------- + Version 2.0.1 +----------------------------------------------------------------------------- + + * Removed automatic group scanning until I get it working + as it should. + +----------------------------------------------------------------------------- + Version 2.0.0 +----------------------------------------------------------------------------- + + * Fixed small bug that was counting too many items for + some players. + + * Added your items to tooltip when mousing over yourself + just like when mousing over other players. + +----------------------------------------------------------------------------- + Version 2.0.0 +----------------------------------------------------------------------------- + + * Converted the addon to use the Ace Libraries. + + * Revamped a lot of old functions. + + * Added list of items equipped to tooltip with item levels + as well as the usual equipped average item level. + +----------------------------------------------------------------------------- + Version 1.4.4 +----------------------------------------------------------------------------- + + * Removed the TitanPanel specific support and added + LDB support instead. Tested with ChocolateBar and + seems to work fine. + +----------------------------------------------------------------------------- + Version 1.4.3 +----------------------------------------------------------------------------- + + * Removed login message. + + * Added a preliminary version of TitanEAILT for + compatibility with Titan Panel. It is TitanDefense modified + to work for EAILT. + +----------------------------------------------------------------------------- + Version 1.4.2 +----------------------------------------------------------------------------- + + * Cumulative small adjustments and tweaks. + +----------------------------------------------------------------------------- + Version 1.4.1 +----------------------------------------------------------------------------- + + * Hopefully fixed a bug that was causing an error message. + + * Various unspecified small tweaks. + +----------------------------------------------------------------------------- + Version 1.4.0 +----------------------------------------------------------------------------- + + * Fairly major rewrite of the code. + + * Removed addon communication and guild roster feature(s). + + * Made the addon double scan people to obtain accurate information. + + * Addon now only tracks equipped item level of people who have been + scanned during the current session. + +----------------------------------------------------------------------------- + Version 1.3.9 +----------------------------------------------------------------------------- + + * Updated the code and did some cleaning. + + * Added a delay before updating tooltip which should force the addon to wait + a few seconds until all the information about a person's ilvl is available. + +----------------------------------------------------------------------------- + Version 1.3.8 +----------------------------------------------------------------------------- + + * Added an in-game configuration which can be accessed via "/ilvl", "/eailt" or + "/eail". This eliminates the need to edit any of the lua files for configuration + and I eventually hope to expand on this section adding useful information + and more configuration options for further customization. + +----------------------------------------------------------------------------- + Version 1.3.7 +----------------------------------------------------------------------------- + + * Resolved an issue with large number of decimal places being displayed for + your own gear. + + * Added two variables to the top of the Core.lua file. EAILT_DEC and + EAILT_IGNORE_EMPTY. EAILT_DEC is the number of decimal places to + display and EAILT_IGNORE_EMPTY changes whether empty equipment + slots are ignore when determining ilvl. Blizzard does not care if you have + three pieces of gear on or sixteen, they will calculate item level as if + you had sixteen (seventeen in the case of dual wield) items equipped. + These two variables may become an in-game config later, but for now + they give a quick and dirty way for users to customize the addon just + a bit. + +----------------------------------------------------------------------------- + Version 1.3.6 +----------------------------------------------------------------------------- + + * More debugging and tweaking. + +----------------------------------------------------------------------------- + Version 1.3.5 +----------------------------------------------------------------------------- + + * More debugging and tweaking trying to get everything working inspite of + the limitation imposed by Blizzard. + + * Thanks to Fastlane [Hellscream] for his assistance in testing and input + which ultimately has led to what I hope are some improvements. + +----------------------------------------------------------------------------- + Version 1.3.4 +----------------------------------------------------------------------------- + + * Debugging code. + +----------------------------------------------------------------------------- + Version 1.3.3 +----------------------------------------------------------------------------- + + * Revised some code to hopefully make things run smoother. + + * Added background scanning for raid/party to collect item levels without + having to mouseover people. Hope to add a frame in the near future to + display party/raid item levels in order from highest to lowest. + +----------------------------------------------------------------------------- + Version 1.3.3 +----------------------------------------------------------------------------- + + * Changed the way item level was calculated slightly so the numbers would + coincide with blizzard's numbers. Previously the addon ignored empty slots, + but blizzard does not ignore those slots when calculating equipped item + levels. Now my addon won't ignore them either. If someone is half dressed + their item level will reflect their lack of equipment. + +----------------------------------------------------------------------------- + Version 1.3.3 +----------------------------------------------------------------------------- + + * Tweaked the tooltip update to hopefully overcome an issue that was leaving + some people stuck on an infinite "Loading..." message in their tooltip. + +----------------------------------------------------------------------------- + Version 1.3.2 +----------------------------------------------------------------------------- + + * Fixed a capitalization mistake which was causing the addon not to function. + +----------------------------------------------------------------------------- + Version 1.3.1 +----------------------------------------------------------------------------- + + * Updated TOC for 4.3. + + * Hopefully resolved the issues that arose with 4.3 and transmogrified gear + giving inaccurate item levels. + + * Hopefully tooltips no longer require you to "re-mouseover" a player to get + their information, but automatically update the tooltip instead. + + * Removed player item level from the paperdoll frame since blizzard made theirs + "Item Level: equipped / average" thus making it pointless for me to add the + information. + + * Added 2 decimal points to the item equipped item level. + + * Hopefully eliminated some of the error messages displayed in the chat frame + for things like mousing over a person under the affects of "Herbouflage". + +----------------------------------------------------------------------------- + Version 1.2.0 +----------------------------------------------------------------------------- + + * More debugging fixed (hopefully) some more little nuances and got some + features finally working like they should. + +----------------------------------------------------------------------------- + Version 1.1.9 +----------------------------------------------------------------------------- + + * Did a little more debugging found an error where sometimes + the realm was nil and concatinating it with unit name was + causing an error. This is the same error reported by + JohnDoe03. + +----------------------------------------------------------------------------- + Version 1.1.8 +----------------------------------------------------------------------------- + + * Did a little debugging hopefully if other people in your party + even from other realms are using the addon then it will + properly show their item levels. + +----------------------------------------------------------------------------- + Version 1.1.7 +----------------------------------------------------------------------------- + + * Updated the .TOC for patch 4.2. + +----------------------------------------------------------------------------- + Version 1.1.6 +----------------------------------------------------------------------------- + + * Tweak the internal addon communication to eliminate the "You + are not in a raid group." message while in battle grounds. + +----------------------------------------------------------------------------- + Version 1.1.5 +----------------------------------------------------------------------------- + + * Updated the .TOC for patch 4.1. + +----------------------------------------------------------------------------- + Version 1.1.4 +----------------------------------------------------------------------------- + + * More tweaking to eliminate bugs. One of which reported by + Meneldor. + +----------------------------------------------------------------------------- + Version 1.1.3 +----------------------------------------------------------------------------- + + * Unspecified bug fix. + +----------------------------------------------------------------------------- + Version 1.1.2 +----------------------------------------------------------------------------- + + * More tweaking to eliminate bugs. + + * Added "Equipped iLvl" to the paperdoll frame. Open your character + paperdoll frame and look under the general stats and it will be + located right above your blizzard item level. + +----------------------------------------------------------------------------- + Version 1.1.1 +----------------------------------------------------------------------------- + + * Fixed an issue with tooltips not populating the information. + + * Added a small frame under guild member detail frame to show + item level equipped and average of guild members who also + use the addon or that you have "scanned" yourself. (Note: + The information is not saved between sessions to cut down + on database size and to force you to get the freshest data + for PUGs.) + +----------------------------------------------------------------------------- + Version 1.1.0 +----------------------------------------------------------------------------- + + * I discovered a problem with the Blizzard code and wrote a little + patch to get rid of the error. + + * Added new feature which uses SendAddonMessage() to share + your equipped item level and your average item level from + Blizzard with your party/raid members. This is so you will get + more information a little bit sooner. Even if you are not in + inspect range if the other members of your party/raid have + the addon you'll get their information asap. + +----------------------------------------------------------------------------- + Version 1.0.0 +----------------------------------------------------------------------------- + + * Original Release \ No newline at end of file diff --git a/Core.lua b/Core.lua new file mode 100644 index 0000000..5d6f8d6 --- /dev/null +++ b/Core.lua @@ -0,0 +1,1009 @@ +----------------------------------------------- +-- INITIALIZE SETTINGS / LOAD ACE LIBRARIES -- +----------------------------------------------- + +local addonName = ... +local VERSION = GetAddOnMetadata(addonName, "Version") +local PREFIX = "EAILT" + +local addon = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceEvent-3.0", "AceHook-3.0", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "AceConsole-3.0") +local LibQTip = LibStub("LibQTip-1.0") +local AceGUI = LibStub("AceGUI-3.0") + +UnitItemLevelDB = {} -- Global table of data so other addons can use our information. +lastInspectRequest = 0 -- Global variable so other addons can use our inspect times to throttle themselves. + +local defaults = { + profile = { + decimal_places = 1, -- (0-9) number of decimal places (IE 400.543 or 400.5) to show on item levels. + show_spec = true, -- (true/false) toggle showing talent spec on mouseover. + show_items = true, -- (true/false) toggle showing list of slots with ilvl on tooltip. + inspectDelay = 1, -- Time (in seconds) to delay between calls to NotifyInspect(unit) [The function which sends requests for player information to the server] + }, +} + +function addon:OnInitialize() + addon.settings = LibStub("AceDB-3.0"):New(addonName.."DB", defaults, true) + + addon.invSlots = { + [1] = "Helm", + [2] = "Neck", + [3] = "Shoulders", + [5] = "Chest", + [6] = "Belt", + [7] = "Legs", + [8] = "Boots", + [9] = "Bracers", + [10] = "Gloves", + [11] = "Ring 1", + [12] = "Ring 2", + [13] = "Trinket 1", + [14] = "Trinket 2", + [15] = "Cloak", + [16] = "Main Hand", + [17] = "Off Hand", + } + + addon.itemUpgrade = { + ["0"]=0, + ["1"]=8, + ["373"]=4, + ["374"]=8, + ["375"]=4, + ["376"]=4, + ["377"]=4, + ["379"]=4, + ["380"]=4, + ["445"]=0, + ["446"]=4, + ["447"]=8, + ["451"]=0, + ["452"]=8, + ["453"]=0, + ["454"]=4, + ["455"]=8, + ["456"]=0, + ["457"]=8, + ["458"]=0, + ["459"]=4, + ["460"]=8, + ["461"]=12, + ["462"]=16, + ["466"]=4, + ["467"]=8, + } + + addon:RegisterComm(PREFIX) +end + +----------------------------------------------- +-- SLASH COMMAND FUNCTION(S) -- +----------------------------------------------- + +function addon:SlashCommand(cmd, self) + addon:ShowGUI() + + --[[ + local i, arg, args = 1, nil, {} + + while addon:GetArgs(cmd, 1, i) do + arg, i = addon:GetArgs(cmd, 1, i) + table.insert(args, arg) + end + + if #args >= 1 then + if args[1] == "show" then + if #args < 2 then + print("/eailt show [spec/items]") + else + if args[2] == "spec" then + if addon.settings.profile.show_spec == true then + addon.settings.profile.show_spec = false + else + addon.settings.profile.show_spec = true + end + print("EAILT show specialization: "..addon.settings.profile.show_spec) + elseif args[2] == "items" then + if addon.settings.profile.show_items == true then + addon.settings.profile.show_items = false + else + addon.settings.profile.show_items = true + end + print("EAILT show item list: "..addon.settings.profile.show_items) + else + print("/eailt show [spec/items]") + end + end + elseif args[1] == "decimal" then + if #args < 2 then + print("/eailt decimal [0-9]") + else + if args[2]:tonumber() > 9 or args[2]:tonumber() < 0 then + print("/eailt decimal [0-9]") + print(" current: "..addon.settings.profile.decimal_places) + print(" default: "..defaults.profile.decimal_places) + else + addon.settings.profile.decimal_places = args[2]:tonumber() + end + end + elseif args[1] == "delay" then + if #args < 2 then + print("/eailt delay [0-9]") + print(" current: "..addon.settings.profile.inspectDelay) + print(" default: "..defaults.profile.inspectDelay) + else + if args[2]:tonumber() > 9 or args[2]:tonumber() < 0 then + print("/eailt delay [0-9]") + else + addon.settings.profile.inspectDelay = args[2]:tonumber() + print("EAILT inspect delay: "..addon.settings.profile.inspectDelay) + end + end + elseif args[1] == "reset" then + -- reset to default settings + elseif args[1] == "config" then + addon:ShowGUI() + else + -- print options list + print("/eailt - Display this help.") + print(" config - open the GUI interface.") + print(" show spec - toggle showing specialization in tooltip.") + print(" show items - toggle showing items list in tooltip.") + print(" decimal # - set number of decimal places to show in item levels.") + print(" delay # - set number of seconds between inspect requests.") + print(" reset - reset all settings back to default.") + end + else + -- print options list + print("/eailt - Display this help.") + print(" config - open the GUI interface.") + print(" show spec - toggle showing specialization in tooltip.") + print(" show items - toggle showing items list in tooltip.") + print(" decimal # - set number of decimal places to show in item levels.") + print(" delay # - set number of seconds between inspect requests.") + print(" reset - reset all settings back to default.") + end + + addon:UpdateLDBText() + ]] +end + +----------------------------------------------- +-- AceGUI-3.0 -- +----------------------------------------------- + +function addon:ShowGUI() + local frame = AceGUI:Create("Frame") + frame:SetTitle("Equipped Average Item Level Tooltip") + frame:SetStatusText("Version "..VERSION.." by Isoloedlk of US-Khaz Modan") + frame:SetCallback("OnClose", function(widget) AceGUI:Release(widget) end) + frame:SetWidth(500) + frame:SetHeight(150) + frame:SetLayout("Flow") + + local check = AceGUI:Create("CheckBox") + check:SetLabel("Show Specialization") + check:SetValue(addon.settings.profile.show_spec) + check:SetCallback("OnValueChanged", function(self, method, value) addon.settings.profile.show_spec = value end) + --check:SetCallback("OnValueChanged", function(...) print(...) end) + frame:AddChild(check) + + local check = AceGUI:Create("CheckBox") + check:SetLabel("Show Item List") + check:SetValue(addon.settings.profile.show_items) + check:SetCallback("OnValueChanged", function(self, method, value) addon.settings.profile.show_items = value end) + --check:SetCallback("OnValueChanged", function(...) print(...) end) + frame:AddChild(check) + + local slider = AceGUI:Create("Slider") + slider:SetLabel("Decimal Places") + slider:SetSliderValues(0, 9, 1) + slider:SetValue(addon.settings.profile.decimal_places) + slider:SetCallback("OnValueChanged", function(self, method, value) addon.settings.profile.decimal_places = value end) + --slider:SetCallback("OnValueChanged", function(...) print(...) end) + frame:AddChild(slider) + + local slider = AceGUI:Create("Slider") + slider:SetLabel("Inspect Request Delay") + slider:SetSliderValues(0, 9, 1) + slider:SetValue(addon.settings.profile.inspectDelay) + slider:SetCallback("OnValueChanged", function(self, method, value) addon.settings.profile.inspectDelay = value end) + --slider:SetCallback("OnValueChanged", function(...) print(...) end) + frame:AddChild(slider) +end +----------------------------------------------- +-- GENERAL FUNCTIONS -- +----------------------------------------------- + +function addon:print(msg) + DEFAULT_CHAT_FRAME:AddMessage("|cffaaffcc[EAILT]:|r "..msg) +end + +function addon:IsPvP() + local retVal = false + local instanceType = select(2, IsInInstance()) + + if instanceType == "arena" or instanceType == "pvp" then + retVal = true + end + + return retVal, instanceType +end + +function addon:showSpecFilter() + local filter = { + bTooltip = false, + TipTacTalents = false, + } + + for k, v in pairs(filter) do + if k == "TipTacTalents" and TipTac_Config then + if TipTac_Config.showTalents == true and addon.settings.profile.show_spec == true then + filter[k] = true + elseif TipTac_Config.showTalents == false and addon.settings.profile.show_spec == true then + filter[k] = false + end + else + filter[k] = IsAddOnLoaded(k) + end + end + + for k, v in pairs(filter) do + if v == true then return true end + end +end + +----------------------------------------------- +-- MATH FUNCTIONS -- +----------------------------------------------- + +function addon:Round(num) + return tonumber(string.format("%."..addon.settings.profile.decimal_places.."f", num)) +end + +----------------------------------------------- +-- TABLE FUNCTIONS -- +----------------------------------------------- + +function addon:insert(val, key) + local index = addon:search('guid', val.guid) + + if index then + UnitItemLevelDB[index] = val + else + if key then + table.insert(UnitItemLevelDB, key, val) + else + table.insert(UnitItemLevelDB, val) + end + end + + addon:prune() +end + +function addon:remove(key, val) + if val then + table.remove(UnitItemLevelDB, addon:search(key, val)) + else + table.remove(UnitItemLevelDB, key) + end +end + +function addon:search(key, val) + local retVal, retTbl + + for k, v in pairs(UnitItemLevelDB) do + if v[key] == val then + retVal = k + retTbl = v + break + end + end + + return retVal, retTbl +end + +function addon:prune() + local i = 1 + + while #(UnitItemLevelDB) > 50 do + if UnitItemLevelDB[i] then + local found + + for b=1,GetNumGroupMembers(),1 do + local guid = UnitGUID("raid"..b) or UnitGUID("party"..b) + + if guid and guid == UnitItemLevelDB[i].guid then + found = true + break + end + end + + if not found then addon:remove(i) end + end + + i = i + 1 + end +end + +----------------------------------------------- +-- LibDataBroker -- +----------------------------------------------- + +local ldb = LibStub:GetLibrary("LibDataBroker-1.1") + +local function ldbOnEnter(self) + local tooltip = LibQTip:Acquire(addonName.."Tooltip", 3, "LEFT", "CENTER", "RIGHT") + self.tooltip = tooltip + + local dataset = {} + local gType, gMembers + + for i=1,GetNumGroupMembers(),1 do + if UnitExists("raid"..i) then + gType = "raid" + gMembers = GetNumGroupMembers() + break + elseif UnitExists("party"..i) then + gType = "party" + gMembers = GetNumGroupMembers() + break + end + end + + if not gType then return end + + for i=1,gMembers,1 do + local unitGUID = UnitGUID(gType..i) + + if unitGUID and type(unitGUID) == "string" and unitGUID ~= UnitGUID("player") then + local index, data = addon:search('guid', unitGUID) + + if index then + table.insert(dataset, {data.name or "Unknown", data.spec or "???", addon:Round(tonumber(data.equipped)) or 0}) + else + local name = select(6, GetPlayerInfoByGUID(unitGUID)) or "Unknown" + + table.insert(dataset, {name, "???", 0}) + end + end + end + + table.insert(dataset, {UnitName("player"), addon:GetSpec(false), ("%.1f"):format(select(2, GetAverageItemLevel()))}) + + local sortTbl = {} + + for k,v in pairs(dataset) do + table.insert(sortTbl, k) + end + + table.sort(sortTbl, function(a, b) + return tonumber(dataset[a][3]) > tonumber(dataset[b][3]) + end) + + tooltip:AddHeader('Name', 'Specialization', 'Equipped iLvl') + + for k,v in pairs(sortTbl) do + local i, c = tooltip:AddLine(dataset[v][1], dataset[v][2], dataset[v][3]) + + if dataset[v][1] == UnitName("player") then + tooltip:SetLineColor(i, 0, 1, 0, 1) + elseif dataset[v][3] == 0 then + tooltip:SetLineColor(i, 1, 0.5, 0, 1) + else + tooltip:SetLineColor(i, 1, 1, 0, 1) + end + end + + tooltip:SmartAnchorTo(self) + tooltip:Show() +end + +local function ldbOnLeave(self) + LibQTip:Release(self.tooltip) + self.tooltip = nil +end + + +function ldbOnClick(self, button) + if button == "LeftButton" then + if GetNumGroupMembers() < 1 then + addon:print("You are not in a group.") + return + end + + if addon:IsPvP() then + addon:print("You are in PvP.") + return + end + + local dataset = {} + local gMembers, gType + + for i=1,GetNumGroupMembers(),1 do + if UnitExists("raid"..i) then + gType = "raid" + gMembers = GetNumGroupMembers() + break + elseif UnitExists("party"..i) then + gType = "party" + gMembers = GetNumGroupMembers() + break + end + end + + for i=1,gMembers,1 do + local unitGUID = UnitGUID(gType..i) + + if unitGUID and type(unitGUID) == "string" and unitGUID ~= UnitGUID("player") then + local index, data = addon:search('guid', unitGUID) + + if index then + table.insert(dataset, {data.name or "Unknown", ("%.1f"):format(tonumber(data.equipped)), data.spec or "None"}) + else + local name = select(6, GetPlayerInfoByGUID(unitGUID)) or "Unknown" + + table.insert(dataset, {name, 0, "None"}) + end + end + end + + table.insert(dataset, {UnitName("player"), addon:Round(select(2, GetAverageItemLevel())), select(2, GetSpecializationInfo(GetSpecialization()))}) + + local sortTbl = {} + + for k,v in pairs(dataset) do + table.insert(sortTbl, k) + end + + table.sort(sortTbl, function(a, b) + return tonumber(dataset[a][2]) > tonumber(dataset[b][2]) + end) + + SendChatMessage("Group Item Levels:", gType) + + for k,v in pairs(sortTbl) do + SendChatMessage(dataset[v][1].." ["..dataset[v][3].."] "..dataset[v][2], gType) + end + end +end + +local dataobj = ldb:NewDataObject(addonName, { + type = "data source", + text = "ilvl(s): Loading...", + OnEnter = ldbOnEnter, + OnLeave = ldbOnLeave, + OnTooltipShow = ldbOnTooltipShow, + OnClick = ldbOnClick, +}) + +function addon:UpdateLDBText() + local avg, equipped = GetAverageItemLevel() + + dataobj.text = "ilvl(s): "..addon:Round(equipped).." / "..addon:Round(avg) +end + +----------------------------------------------- +-- ENABLE/DISABLE ADDON FUNCTIONS -- +----------------------------------------------- + +function addon:OnEnable() + self:RegisterEvent("INSPECT_READY") + + --self:RegisterEvent("ADDON_LOADED") + + self:RegisterEvent("UNIT_INVENTORY_CHANGED") + self:RegisterEvent("PLAYER_AVG_ITEM_LEVEL_READY") + self:RegisterEvent("RAID_ROSTER_UPDATE") + self:RegisterEvent("PARTY_MEMBERS_CHANGED") + self:RegisterEvent("PLAYER_ENTERING_WORLD") + + self:Hook("NotifyInspect", true) + + self:SecureHookScript(GameTooltip, "OnTooltipSetUnit", addon['OnTooltipSetUnit']) + --self:SecureHookScript(GameTooltip, "OnShow", addon['TooltipOnShow']) + --self:SecureHookScript(GameTooltip, "OnHide", addon['TooltipOnHide']) + + --self:SecureHook(GameTooltip, "AddDoubleLine", addon['AddDoubleLine']) + + self:RegisterChatCommand("eailt", "SlashCommand", true) + + addon:UpdateLDBText() + + --addon:print(addonName.." version "..VERSION.." enabled.") +end + +function addon:OnDisable() + self:UnregisterEvent("INSPECT_READY") + + --self:UnregisterEvent("ADDON_LOADED") + + self:UnregisterEvent("UNIT_INVENTORY_CHANGED") + self:UnregisterEvent("PLAYER_AVG_ITEM_LEVEL_READY") + self:UnregisterEvent("RAID_ROSTER_UPDATE") + self:UnregisterEvent("PARTY_MEMBERS_CHANGED") + self:UnregisterEvent("PLAYER_ENTERING_WORLD") + + self:UnHook("NotifyInspect") + + self:UnHook(GameTooltip, "OnTooltipSetUnit") + --self:UnHook(GameTooltip, "OnShow") + --self:UnHook(GameTooltip, "OnHide") + + self:UnregisterChatCommand("eailt") + + self:CancelAllTimers() + + --addon:print(addonName.." version "..VERSION.." disabled.") +end + +----------------------------------------------- +-- EVENTS/HOOKS -- +----------------------------------------------- + +function addon:NotifyInspect(unitID) +--[[ + --if not InspectFrame then + -- LoadAddOn("Blizzard_InspectUI") + --end + + if ( InspectFrame and InspectFrame:IsVisible() ) or ( Examiner and Examiner:IsVisible() ) then + InspectFrame.unit = "target" + --else + --InspectFrame.unit = "player" + elseif InspectFrame then + InspectFrame.unit = unitID + end +]] + addon.guid = UnitGUID(unitID) + lastInspectRequest = GetTime() +end + +function addon:INSPECT_READY(_, unitGUID) + local ilvl, items = addon:GetUnitItemLevelGUID(unitGUID) + local index, tbl = addon:search('guid', unitGUID) + local count = 0 + local spec = "..." + + if unitGUID == addon.guid then spec = addon:GetSpec(true) end + + if index then + count = tbl.scanCount + if (count or 1) < 2 then addon:Inspect(addon:GetUnitByGUID(unitGUID)) end + end + + if #(items or {}) <= 7 then + addon:Inspect(addon:GetUnitByGUID(unitGUID)) + end + + if ilvl then + addon:insert({ + ['guid'] = unitGUID, + ['name'] = select(6, GetPlayerInfoByGUID(unitGUID)), + ['equipped'] = ilvl, + ['items'] = items, + ['spec'] = spec, + ['scanCount'] = count, + }) + + addon:UpdateTooltip() + end +end + +--[[function addon:ADDON_LOADED(_, name) + if name == "TipTacTalents" or IsAddOnLoaded("TipTacTalents") then + if TipTac_Config then + if TipTac_Config.showTalents == true then + addon.settings.profile.show_spec = false + end + else + addon.settings.profile.show_spec = false + end + + --addon:UnregisterEvent("ADDON_LOADED") + elseif name == "bTooltip" or IsAddOnLoaded("bTooltip") then + addon.settings.profile.show_spec = false + end +end]] + +function addon:PLAYER_AVG_ITEM_LEVEL_READY(...) + addon:UpdateLDBText() +end + +function addon:UNIT_INVENTORY_CHANGED(_, unitID) + local gType + + if UnitGUID(unitID) ~= UnitGUID("player") then + addon:remove('guid', UnitGUID(unitID)) + + addon:Inspect(unitID) + else + for i=1,GetNumGroupMembers(),1 do + if UnitExists("raid"..i) then + gType = "raid" + break + elseif UnitExists("party"..i) then + gType = "party" + break + end + end + + if gType and addon:IsPvP() == false then + addon:SendItemInfo(gType:upper()) + end + + addon:UpdateLDBText() + end +end + +----------------------------------------------- +-- ADDON COMMS -- +----------------------------------------------- + +function addon:GroupType() + if select(2, IsInInstance()) == "pvp" or select(2, IsInInstance()) == "arena" then + return false, "none" + end + + for i=1,GetNumGroupMembers(),1 do + if UnitExists("raid"..i) then + return true, "raid" + end + end + + for i=1,GetNumGroupMembers(),1 do + if UnitExists("party"..i) then + return true, "party" + end + end +end + +function addon:PLAYER_ENTERING_WORLD() + local isGroup, groupType = addon:GroupType() + + if isGroup then + addon:SendCommMessage(PREFIX, addon:Serialize({type = "REQUEST_INFO"}), groupType:upper(), nil, "NORMAL") + end +end + +function addon:RAID_ROSTER_UPDATE() + local isGroup, groupType = addon:GroupType() + + if isGroup and groupType == "raid" then + addon:SendVersion("RAID") + addon:SendItemInfo("RAID") + end +end + +function addon:PARTY_MEMBERS_CHANGED() + local isGroup, groupType = addon:GroupType() + + if isGroup and groupType == "party" then + addon:SendVersion("PARTY") + addon:SendItemInfo("PARTY") + end +end + +function addon:SendVersion(gType) + addon:SendCommMessage(PREFIX, addon:Serialize({type = "VERSION", msg = VERSION}), gType, nil, "NORMAL") +end + +function addon:SendItemInfo(gType) + local ilvl, items = addon:GetUnitItemLevel("player") + + addon:SendCommMessage(PREFIX, addon:Serialize({type = "ITEM_INFO", msg = { + ['guid'] = UnitGUID("player"), + ['name'] = UnitName("player"), + ['equipped'] = ilvl, + ['items'] = items, + }}), gType, nil, "NORMAL") +end + +function addon:OnCommReceived(pre, msg, chan, sender) + if pre == PREFIX and sender ~= UnitName("player") then + local _, data = addon:Deserialize(msg) + + if data.type == "VERSION" and data.msg > VERSION and ( addon.versionWarning or 0 ) == 0 then + addon:print("A newer version is available. Visit http://www.wowinterface.com to download the latest version.") + addon.versionWarning = 1 + elseif data.type == "ITEM_INFO" then + --addon:print("Received item info from "..sender) + addon:insert(data.msg) + elseif data.type == "REQUEST_INFO" then + addon:SendItemInfo(chan) + end + end +end + +----------------------------------------------- +-- TOOLTIP FUNCTIONS -- +----------------------------------------------- + +function addon:searchTT(val) + local retVal + + for i=2, GameTooltip:NumLines()+1 do + local txt = _G["GameTooltipTextLeft"..i]:GetText() or "" + + if txt:find(val) then + retVal = i + break + end + end + + return retVal +end + +function addon:OnTooltipSetUnit() + local _, unit = self:GetUnit() + + addon:Inspect(unit) + + if unit and UnitGUID(unit) == UnitGUID("player") then + local ilvl, items = addon:GetUnitItemLevel("player") + + addon:insert({ + ['guid'] = UnitGUID("player"), + ['name'] = UnitName("player"), + ['equipped'] = ilvl, + ['items'] = items, + ['spec'] = addon:GetSpec(false), + ['scanCount'] = 2, + }) + + if addon.settings.profile.show_spec and not addon:showSpecFilter() and UnitLevel("player") >= 10 then + self:AddLine("Spec: |cffffffff"..select(2, GetSpecializationInfo(GetSpecialization()))) + if not self.fadeOut then self:Show() end + end + + self:AddLine("iLvl: |cffff8000"..addon:Round(ilvl)) + if not self.fadeOut then self:Show() end + + if addon.settings.profile.show_items then + for i=1,17,1 do + if i ~= 4 and items[i] then + self:AddDoubleLine(addon.invSlots[i], "|c"..items[i].color..items[i].name.." |cffffffff("..(items[i].itemLevel or "???")..")") + if not self.fadeOut then self:Show() end + elseif i ~= 4 then + self:AddDoubleLine(addon.invSlots[i], "|cffaaaaaaNone/Not Scanned |cffffffff(???)") + if not self.fadeOut then self:Show() end + end + end + end + elseif unit and UnitIsPlayer(unit) then + if addon.settings.profile.show_spec and not addon:showSpecFilter() and UnitLevel(unit) >= 10 then + self:AddLine("Spec: |cffffffff...") + self:Show() + end + + self:AddLine("iLvl: |cffff8000...", 1, 1, 1) + if not self.fadeOut then self:Show() end + + if addon.settings.profile.show_items then + for i=1,17,1 do + if i ~= 4 then + self:AddDoubleLine(addon.invSlots[i], "|cffaaaaaaNone/Not Scanned |cffffffff(???)") + if not self.fadeOut then self:Show() end + end + --GameTooltip:Show() + end + end + end + + addon:UpdateTooltip() +end + +function addon:TooltipOnShow() + --if GameTooltip:GetUnit() then print("It's a unit!") end + addon.tooltiptimer = addon:ScheduleRepeatingTimer("UpdateTooltip", 0.2) +end + +function addon:TooltipOnHide() + --GameTooltip:SetMinResize(0, 0) + addon:CancelTimer(addon.tooltiptimer) +end + +function addon:UpdateTooltip() + if GameTooltip:GetUnit() then + local name, unit = GameTooltip:GetUnit() + + if not unit or not UnitIsPlayer(unit) then return end + + local index, data = addon:search('guid', UnitGUID(unit)) + + if index then + local found + + if addon.settings.profile.show_spec and data.spec and not addon:showSpecFilter() then + found = addon:searchTT("Spec:") + + if found then + _G["GameTooltipTextLeft"..found]:SetFormattedText("Spec: |cffffffff%s", data.spec) + else + GameTooltip:AddLine("Spec: |cffffffff"..data.spec) + GameTooltip:Show() + end + end + + found = addon:searchTT("iLvl:") + + if found then + _G["GameTooltipTextLeft"..found]:SetFormattedText("iLvl: |cffff8000%s", data.equipped) + else + GameTooltip:AddLine("iLvl: |cffff8800"..data.equipped) + if not GameTooltip.fadeOut then GameTooltip:Show() end + end + + if addon.settings.profile.show_items then + + for i=1, 17,1 do + if i ~= 4 then + found = addon:searchTT(addon.invSlots[i]) + + if found then + if data.items[i] then + _G["GameTooltipTextRight"..found]:SetFormattedText("|c%s%s |cffffffff(%s)", data.items[i].color, data.items[i].name, data.items[i].itemLevel) + else + _G["GameTooltipTextRight"..found]:SetFormattedText("|c%s%s |cffffffff(%s)", "ffaaaaaa", "None/Not Scanned", "???") + end + if not GameTooltip.fadeOut then GameTooltip:Show() end + else + if data.items[i] then + GameTooltip:AddDoubleLine(addon.invSlots[i], "|c"..data.items[i].color..data.items[i].name.." |cffffffff("..(data.items[i].itemLevel or "???")..")") + else + GameTooltip:AddDoubleLine(addon.invSlots[i], "|cffaaaaaaNone/Not Scanned |cffffffff(???)") + end + if not GameTooltip.fadeOut then GameTooltip:Show() end + end + end + end + end + end + end +end + +--[[function addon:AddDoubleLine(...) + if not GameTooltip.fadeOut then + GameTooltip:Show() + end +end]] + +--[[function addon:RefreshGameTooltip() + local lwidth, rwidth, width, index + + index = addon:searchTT(addon.invSlots[1]) + + for i=index,GameTooltip:NumLines(),1 do + local l, r = _G["GameTooltipTextLeft"..i], _G["GameTooltipTextRight"..i] + + if l:GetWidth() >= ( lwidth or 0 ) then + lwidth = l:GetWidth() + end + + if r:GetWidth() >= ( rwidth or 0 ) then + rwidth = r:GetWidth() + end + + width = lwidth + rwidth + 50 + end + + for i=index,GameTooltip:NumLines(),1 do + local l, r = _G["GameTooltipTextLeft"..i], _G["GameTooltipTextRight"..i] + + r:SetPoint("RIGHT", l, "LEFT", width - 22, 0) + end + + GameTooltip:SetWidth(width) + GameTooltip:Show() +end]] + +----------------------------------------------- +-- INSPECT FUNCTION(S) -- +----------------------------------------------- + +function addon:Inspect(unit) + addon:CancelTimer(addon.inspectTimer, true) + + if unit and UnitExists(unit) and not UnitIsUnit(unit, "player") then + if CanInspect(unit, false) and CheckInteractDistance(unit, 1) and ( GetTime() - lastInspectRequest ) >= addon.settings.profile.inspectDelay and not ( ( InspectFrame and InspectFrame:IsVisible() ) or ( Examiner and Examiner:IsVisible() ) ) then + NotifyInspect(unit) + else + addon.inspectTimer = addon:ScheduleTimer("Inspect", addon.settings.profile.inspectDelay, unit) + end + end +end + +----------------------------------------------- +-- ITEMLEVEL FUNCTIONS -- +----------------------------------------------- + +function addon:GetUnitByGUID(unitGUID) + local unitID + + for i = 1, 4, 1 do + if UnitGUID("party"..i) == unitGUID then unitID = "party"..i end + end + + for i = 1, 40, 1 do + if UnitGUID("raid"..i) == unitGUID then unitID = "raid"..i end + end + + if UnitGUID("player") == unitGUID then + unitID = "player" + elseif UnitGUID("mouseover") == unitGUID then + unitID = "mouseover" + elseif UnitGUID("target") == unitGUID then + unitID = "target" + elseif UnitGUID("focus") == unitGUID then + unitID = "focus" + end + + return unitID +end + +function addon:GetUnitItemLevel(unit) + local items = {} + local sum, count + + if unit and UnitIsPlayer(unit) and CheckInteractDistance(unit, 1) then + for i=1, 17, 1 do + local link = GetInventoryItemLink(unit, i) + local name, _, quality, itemLevel = GetItemInfo(link or 0) + local color = select(4, GetItemQualityColor(quality or 1)) + + if itemLevel and itemLevel > 0 and i ~= 4 then + local upgrade = string.match(link, ":(%d+)\124h%[") + if upgrade then + itemLevel = itemLevel + (addon.itemUpgrade[upgrade] or 0) + end + + table.insert(items, i, { + ['name'] = name, + ['itemLevel'] = itemLevel, + ['color'] = color, + ['slotName'] = addon.invSlots[i], + }) + sum = (sum or 0) + itemLevel + count = (count or 0) + 1 + end + end + + if (sum or 0) >= (count or 0) and (count or 0) > 0 then + return addon:Round(sum/count), items + else + return nil, nil + end + end +end + +function addon:GetUnitItemLevelGUID(unitGUID) + return addon:GetUnitItemLevel(addon:GetUnitByGUID(unitGUID)) +end + +function addon:GetGUIDByName(name) + local index, data = addon:search('name', name) + + return data.guid or nil +end + +----------------------------------------------- +-- TALENT FUNCTIONS -- +----------------------------------------------- + +function addon:GetSpec(useGlobal) + local name + + if useGlobal then + local unit = addon:GetUnitByGUID(addon.guid) + + if unit and UnitLevel(unit) >= 10 then + name = select(2, GetSpecializationInfoByID(GetInspectSpecialization(unit))) + end + else + if UnitLevel("player") >= 10 then + name = select(2, GetSpecializationInfo(GetSpecialization())) + end + end + + return name or "None" +end \ No newline at end of file diff --git a/EquippedItemLevelTooltip.toc b/EquippedItemLevelTooltip.toc new file mode 100644 index 0000000..dd13cec --- /dev/null +++ b/EquippedItemLevelTooltip.toc @@ -0,0 +1,25 @@ +## Interface: 50300 +## Title: EquippedItemLevelTooltip +## Notes: Adds the equipped average item level of people to your tooltip. +## Author: Cowmonster (http://www.wowinterface.com) +## Version: 2.1.1 +## SavedVariables: EquippedItemLevelTooltipDB + +Libs\LibStub\Libstub.lua +Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml + +Libs\AceAddon-3.0\AceAddon-3.0.lua +Libs\AceComm-3.0\ChatThrottleLib.lua +Libs\AceComm-3.0\AceComm-3.0.lua +Libs\AceConsole-3.0\AceConsole-3.0.lua +Libs\AceDB-3.0\AceDB-3.0.lua +Libs\AceEvent-3.0\AceEvent-3.0.lua +Libs\AceGUI-3.0\AceGUI-3.0.lua +Libs\AceHook-3.0\AceHook-3.0.lua +Libs\AceSerializer-3.0\AceSerializer-3.0.lua +Libs\AceTimer-3.0\AceTimer-3.0.lua + +Libs\libdatabroker-1-1\LibDataBroker-1.1.lua +Libs\LibQTip-1.0\LibQTip-1.0.lua + +Core.lua \ No newline at end of file diff --git a/Libs/AceAddon-3.0/AceAddon-3.0.lua b/Libs/AceAddon-3.0/AceAddon-3.0.lua new file mode 100644 index 0000000..1c9abf1 --- /dev/null +++ b/Libs/AceAddon-3.0/AceAddon-3.0.lua @@ -0,0 +1,659 @@ +--- **AceAddon-3.0** provides a template for creating addon objects. +-- It'll provide you with a set of callback functions that allow you to simplify the loading +-- process of your addon.\\ +-- Callbacks provided are:\\ +-- * **OnInitialize**, which is called directly after the addon is fully loaded. +-- * **OnEnable** which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present. +-- * **OnDisable**, which is only called when your addon is manually being disabled. +-- @usage +-- -- A small (but complete) addon, that doesn't do anything, +-- -- but shows usage of the callbacks. +-- local MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") +-- +-- function MyAddon:OnInitialize() +-- -- do init tasks here, like loading the Saved Variables, +-- -- or setting up slash commands. +-- end +-- +-- function MyAddon:OnEnable() +-- -- Do more initialization here, that really enables the use of your addon. +-- -- Register Events, Hook functions, Create Frames, Get information from +-- -- the game that wasn't available in OnInitialize +-- end +-- +-- function MyAddon:OnDisable() +-- -- Unhook, Unregister Events, Hide frames that you created. +-- -- You would probably only use an OnDisable if you want to +-- -- build a "standby" mode, or be able to toggle modules on/off. +-- end +-- @class file +-- @name AceAddon-3.0.lua +-- @release $Id: AceAddon-3.0.lua 1036 2011-08-16 22:45:05Z nevcairiel $ + +local MAJOR, MINOR = "AceAddon-3.0", 11 +local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR) + +if not AceAddon then return end -- No Upgrade needed. + +AceAddon.frame = AceAddon.frame or CreateFrame("Frame", "AceAddon30Frame") -- Our very own frame +AceAddon.addons = AceAddon.addons or {} -- addons in general +AceAddon.statuses = AceAddon.statuses or {} -- statuses of addon. +AceAddon.initializequeue = AceAddon.initializequeue or {} -- addons that are new and not initialized +AceAddon.enablequeue = AceAddon.enablequeue or {} -- addons that are initialized and waiting to be enabled +AceAddon.embeds = AceAddon.embeds or setmetatable({}, {__index = function(tbl, key) tbl[key] = {} return tbl[key] end }) -- contains a list of libraries embedded in an addon + +-- Lua APIs +local tinsert, tconcat, tremove = table.insert, table.concat, table.remove +local fmt, tostring = string.format, tostring +local select, pairs, next, type, unpack = select, pairs, next, type, unpack +local loadstring, assert, error = loadstring, assert, error +local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget + +-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded +-- List them here for Mikk's FindGlobals script +-- GLOBALS: LibStub, IsLoggedIn, geterrorhandler + +--[[ + xpcall safecall implementation +]] +local xpcall = xpcall + +local function errorhandler(err) + return geterrorhandler()(err) +end + +local function CreateDispatcher(argCount) + local code = [[ + local xpcall, eh = ... + local method, ARGS + local function call() return method(ARGS) end + + local function dispatch(func, ...) + method = func + if not method then return end + ARGS = ... + return xpcall(call, eh) + end + + return dispatch + ]] + + local ARGS = {} + for i = 1, argCount do ARGS[i] = "arg"..i end + code = code:gsub("ARGS", tconcat(ARGS, ", ")) + return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler) +end + +local Dispatchers = setmetatable({}, {__index=function(self, argCount) + local dispatcher = CreateDispatcher(argCount) + rawset(self, argCount, dispatcher) + return dispatcher +end}) +Dispatchers[0] = function(func) + return xpcall(func, errorhandler) +end + +local function safecall(func, ...) + -- we check to see if the func is passed is actually a function here and don't error when it isn't + -- this safecall is used for optional functions like OnInitialize OnEnable etc. When they are not + -- present execution should continue without hinderance + if type(func) == "function" then + return Dispatchers[select('#', ...)](func, ...) + end +end + +-- local functions that will be implemented further down +local Enable, Disable, EnableModule, DisableModule, Embed, NewModule, GetModule, GetName, SetDefaultModuleState, SetDefaultModuleLibraries, SetEnabledState, SetDefaultModulePrototype + +-- used in the addon metatable +local function addontostring( self ) return self.name end + +--- Create a new AceAddon-3.0 addon. +-- Any libraries you specified will be embeded, and the addon will be scheduled for +-- its OnInitialize and OnEnable callbacks. +-- The final addon object, with all libraries embeded, will be returned. +-- @paramsig [object ,]name[, lib, ...] +-- @param object Table to use as a base for the addon (optional) +-- @param name Name of the addon object to create +-- @param lib List of libraries to embed into the addon +-- @usage +-- -- Create a simple addon object +-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceEvent-3.0") +-- +-- -- Create a Addon object based on the table of a frame +-- local MyFrame = CreateFrame("Frame") +-- MyAddon = LibStub("AceAddon-3.0"):NewAddon(MyFrame, "MyAddon", "AceEvent-3.0") +function AceAddon:NewAddon(objectorname, ...) + local object,name + local i=1 + if type(objectorname)=="table" then + object=objectorname + name=... + i=2 + else + name=objectorname + end + if type(name)~="string" then + error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) + end + if self.addons[name] then + error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - Addon '%s' already exists."):format(name), 2) + end + + object = object or {} + object.name = name + + local addonmeta = {} + local oldmeta = getmetatable(object) + if oldmeta then + for k, v in pairs(oldmeta) do addonmeta[k] = v end + end + addonmeta.__tostring = addontostring + + setmetatable( object, addonmeta ) + self.addons[name] = object + object.modules = {} + object.orderedModules = {} + object.defaultModuleLibraries = {} + Embed( object ) -- embed NewModule, GetModule methods + self:EmbedLibraries(object, select(i,...)) + + -- add to queue of addons to be initialized upon ADDON_LOADED + tinsert(self.initializequeue, object) + return object +end + + +--- Get the addon object by its name from the internal AceAddon registry. +-- Throws an error if the addon object cannot be found (except if silent is set). +-- @param name unique name of the addon object +-- @param silent if true, the addon is optional, silently return nil if its not found +-- @usage +-- -- Get the Addon +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +function AceAddon:GetAddon(name, silent) + if not silent and not self.addons[name] then + error(("Usage: GetAddon(name): 'name' - Cannot find an AceAddon '%s'."):format(tostring(name)), 2) + end + return self.addons[name] +end + +-- - Embed a list of libraries into the specified addon. +-- This function will try to embed all of the listed libraries into the addon +-- and error if a single one fails. +-- +-- **Note:** This function is for internal use by :NewAddon/:NewModule +-- @paramsig addon, [lib, ...] +-- @param addon addon object to embed the libs in +-- @param lib List of libraries to embed into the addon +function AceAddon:EmbedLibraries(addon, ...) + for i=1,select("#", ... ) do + local libname = select(i, ...) + self:EmbedLibrary(addon, libname, false, 4) + end +end + +-- - Embed a library into the addon object. +-- This function will check if the specified library is registered with LibStub +-- and if it has a :Embed function to call. It'll error if any of those conditions +-- fails. +-- +-- **Note:** This function is for internal use by :EmbedLibraries +-- @paramsig addon, libname[, silent[, offset]] +-- @param addon addon object to embed the library in +-- @param libname name of the library to embed +-- @param silent marks an embed to fail silently if the library doesn't exist (optional) +-- @param offset will push the error messages back to said offset, defaults to 2 (optional) +function AceAddon:EmbedLibrary(addon, libname, silent, offset) + local lib = LibStub:GetLibrary(libname, true) + if not lib and not silent then + error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Cannot find a library instance of %q."):format(tostring(libname)), offset or 2) + elseif lib and type(lib.Embed) == "function" then + lib:Embed(addon) + tinsert(self.embeds[addon], libname) + return true + elseif lib then + error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Library '%s' is not Embed capable"):format(libname), offset or 2) + end +end + +--- Return the specified module from an addon object. +-- Throws an error if the addon object cannot be found (except if silent is set) +-- @name //addon//:GetModule +-- @paramsig name[, silent] +-- @param name unique name of the module +-- @param silent if true, the module is optional, silently return nil if its not found (optional) +-- @usage +-- -- Get the Addon +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- -- Get the Module +-- MyModule = MyAddon:GetModule("MyModule") +function GetModule(self, name, silent) + if not self.modules[name] and not silent then + error(("Usage: GetModule(name, silent): 'name' - Cannot find module '%s'."):format(tostring(name)), 2) + end + return self.modules[name] +end + +local function IsModuleTrue(self) return true end + +--- Create a new module for the addon. +-- The new module can have its own embeded libraries and/or use a module prototype to be mixed into the module.\\ +-- A module has the same functionality as a real addon, it can have modules of its own, and has the same API as +-- an addon object. +-- @name //addon//:NewModule +-- @paramsig name[, prototype|lib[, lib, ...]] +-- @param name unique name of the module +-- @param prototype object to derive this module from, methods and values from this table will be mixed into the module (optional) +-- @param lib List of libraries to embed into the addon +-- @usage +-- -- Create a module with some embeded libraries +-- MyModule = MyAddon:NewModule("MyModule", "AceEvent-3.0", "AceHook-3.0") +-- +-- -- Create a module with a prototype +-- local prototype = { OnEnable = function(self) print("OnEnable called!") end } +-- MyModule = MyAddon:NewModule("MyModule", prototype, "AceEvent-3.0", "AceHook-3.0") +function NewModule(self, name, prototype, ...) + if type(name) ~= "string" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end + if type(prototype) ~= "string" and type(prototype) ~= "table" and type(prototype) ~= "nil" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'prototype' - table (prototype), string (lib) or nil expected got '%s'."):format(type(prototype)), 2) end + + if self.modules[name] then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - Module '%s' already exists."):format(name), 2) end + + -- modules are basically addons. We treat them as such. They will be added to the initializequeue properly as well. + -- NewModule can only be called after the parent addon is present thus the modules will be initialized after their parent is. + local module = AceAddon:NewAddon(fmt("%s_%s", self.name or tostring(self), name)) + + module.IsModule = IsModuleTrue + module:SetEnabledState(self.defaultModuleState) + module.moduleName = name + + if type(prototype) == "string" then + AceAddon:EmbedLibraries(module, prototype, ...) + else + AceAddon:EmbedLibraries(module, ...) + end + AceAddon:EmbedLibraries(module, unpack(self.defaultModuleLibraries)) + + if not prototype or type(prototype) == "string" then + prototype = self.defaultModulePrototype or nil + end + + if type(prototype) == "table" then + local mt = getmetatable(module) + mt.__index = prototype + setmetatable(module, mt) -- More of a Base class type feel. + end + + safecall(self.OnModuleCreated, self, module) -- Was in Ace2 and I think it could be a cool thing to have handy. + self.modules[name] = module + tinsert(self.orderedModules, module) + + return module +end + +--- Returns the real name of the addon or module, without any prefix. +-- @name //addon//:GetName +-- @paramsig +-- @usage +-- print(MyAddon:GetName()) +-- -- prints "MyAddon" +function GetName(self) + return self.moduleName or self.name +end + +--- Enables the Addon, if possible, return true or false depending on success. +-- This internally calls AceAddon:EnableAddon(), thus dispatching a OnEnable callback +-- and enabling all modules of the addon (unless explicitly disabled).\\ +-- :Enable() also sets the internal `enableState` variable to true +-- @name //addon//:Enable +-- @paramsig +-- @usage +-- -- Enable MyModule +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyModule = MyAddon:GetModule("MyModule") +-- MyModule:Enable() +function Enable(self) + self:SetEnabledState(true) + return AceAddon:EnableAddon(self) +end + +--- Disables the Addon, if possible, return true or false depending on success. +-- This internally calls AceAddon:DisableAddon(), thus dispatching a OnDisable callback +-- and disabling all modules of the addon.\\ +-- :Disable() also sets the internal `enableState` variable to false +-- @name //addon//:Disable +-- @paramsig +-- @usage +-- -- Disable MyAddon +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyAddon:Disable() +function Disable(self) + self:SetEnabledState(false) + return AceAddon:DisableAddon(self) +end + +--- Enables the Module, if possible, return true or false depending on success. +-- Short-hand function that retrieves the module via `:GetModule` and calls `:Enable` on the module object. +-- @name //addon//:EnableModule +-- @paramsig name +-- @usage +-- -- Enable MyModule using :GetModule +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyModule = MyAddon:GetModule("MyModule") +-- MyModule:Enable() +-- +-- -- Enable MyModule using the short-hand +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyAddon:EnableModule("MyModule") +function EnableModule(self, name) + local module = self:GetModule( name ) + return module:Enable() +end + +--- Disables the Module, if possible, return true or false depending on success. +-- Short-hand function that retrieves the module via `:GetModule` and calls `:Disable` on the module object. +-- @name //addon//:DisableModule +-- @paramsig name +-- @usage +-- -- Disable MyModule using :GetModule +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyModule = MyAddon:GetModule("MyModule") +-- MyModule:Disable() +-- +-- -- Disable MyModule using the short-hand +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyAddon:DisableModule("MyModule") +function DisableModule(self, name) + local module = self:GetModule( name ) + return module:Disable() +end + +--- Set the default libraries to be mixed into all modules created by this object. +-- Note that you can only change the default module libraries before any module is created. +-- @name //addon//:SetDefaultModuleLibraries +-- @paramsig lib[, lib, ...] +-- @param lib List of libraries to embed into the addon +-- @usage +-- -- Create the addon object +-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") +-- -- Configure default libraries for modules (all modules need AceEvent-3.0) +-- MyAddon:SetDefaultModuleLibraries("AceEvent-3.0") +-- -- Create a module +-- MyModule = MyAddon:NewModule("MyModule") +function SetDefaultModuleLibraries(self, ...) + if next(self.modules) then + error("Usage: SetDefaultModuleLibraries(...): cannot change the module defaults after a module has been registered.", 2) + end + self.defaultModuleLibraries = {...} +end + +--- Set the default state in which new modules are being created. +-- Note that you can only change the default state before any module is created. +-- @name //addon//:SetDefaultModuleState +-- @paramsig state +-- @param state Default state for new modules, true for enabled, false for disabled +-- @usage +-- -- Create the addon object +-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") +-- -- Set the default state to "disabled" +-- MyAddon:SetDefaultModuleState(false) +-- -- Create a module and explicilty enable it +-- MyModule = MyAddon:NewModule("MyModule") +-- MyModule:Enable() +function SetDefaultModuleState(self, state) + if next(self.modules) then + error("Usage: SetDefaultModuleState(state): cannot change the module defaults after a module has been registered.", 2) + end + self.defaultModuleState = state +end + +--- Set the default prototype to use for new modules on creation. +-- Note that you can only change the default prototype before any module is created. +-- @name //addon//:SetDefaultModulePrototype +-- @paramsig prototype +-- @param prototype Default prototype for the new modules (table) +-- @usage +-- -- Define a prototype +-- local prototype = { OnEnable = function(self) print("OnEnable called!") end } +-- -- Set the default prototype +-- MyAddon:SetDefaultModulePrototype(prototype) +-- -- Create a module and explicitly Enable it +-- MyModule = MyAddon:NewModule("MyModule") +-- MyModule:Enable() +-- -- should print "OnEnable called!" now +-- @see NewModule +function SetDefaultModulePrototype(self, prototype) + if next(self.modules) then + error("Usage: SetDefaultModulePrototype(prototype): cannot change the module defaults after a module has been registered.", 2) + end + if type(prototype) ~= "table" then + error(("Usage: SetDefaultModulePrototype(prototype): 'prototype' - table expected got '%s'."):format(type(prototype)), 2) + end + self.defaultModulePrototype = prototype +end + +--- Set the state of an addon or module +-- This should only be called before any enabling actually happend, e.g. in/before OnInitialize. +-- @name //addon//:SetEnabledState +-- @paramsig state +-- @param state the state of an addon or module (enabled=true, disabled=false) +function SetEnabledState(self, state) + self.enabledState = state +end + + +--- Return an iterator of all modules associated to the addon. +-- @name //addon//:IterateModules +-- @paramsig +-- @usage +-- -- Enable all modules +-- for name, module in MyAddon:IterateModules() do +-- module:Enable() +-- end +local function IterateModules(self) return pairs(self.modules) end + +-- Returns an iterator of all embeds in the addon +-- @name //addon//:IterateEmbeds +-- @paramsig +local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end + +--- Query the enabledState of an addon. +-- @name //addon//:IsEnabled +-- @paramsig +-- @usage +-- if MyAddon:IsEnabled() then +-- MyAddon:Disable() +-- end +local function IsEnabled(self) return self.enabledState end +local mixins = { + NewModule = NewModule, + GetModule = GetModule, + Enable = Enable, + Disable = Disable, + EnableModule = EnableModule, + DisableModule = DisableModule, + IsEnabled = IsEnabled, + SetDefaultModuleLibraries = SetDefaultModuleLibraries, + SetDefaultModuleState = SetDefaultModuleState, + SetDefaultModulePrototype = SetDefaultModulePrototype, + SetEnabledState = SetEnabledState, + IterateModules = IterateModules, + IterateEmbeds = IterateEmbeds, + GetName = GetName, +} +local function IsModule(self) return false end +local pmixins = { + defaultModuleState = true, + enabledState = true, + IsModule = IsModule, +} +-- Embed( target ) +-- target (object) - target object to embed aceaddon in +-- +-- this is a local function specifically since it's meant to be only called internally +function Embed(target, skipPMixins) + for k, v in pairs(mixins) do + target[k] = v + end + if not skipPMixins then + for k, v in pairs(pmixins) do + target[k] = target[k] or v + end + end +end + + +-- - Initialize the addon after creation. +-- This function is only used internally during the ADDON_LOADED event +-- It will call the **OnInitialize** function on the addon object (if present), +-- and the **OnEmbedInitialize** function on all embeded libraries. +-- +-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. +-- @param addon addon object to intialize +function AceAddon:InitializeAddon(addon) + safecall(addon.OnInitialize, addon) + + local embeds = self.embeds[addon] + for i = 1, #embeds do + local lib = LibStub:GetLibrary(embeds[i], true) + if lib then safecall(lib.OnEmbedInitialize, lib, addon) end + end + + -- we don't call InitializeAddon on modules specifically, this is handled + -- from the event handler and only done _once_ +end + +-- - Enable the addon after creation. +-- Note: This function is only used internally during the PLAYER_LOGIN event, or during ADDON_LOADED, +-- if IsLoggedIn() already returns true at that point, e.g. for LoD Addons. +-- It will call the **OnEnable** function on the addon object (if present), +-- and the **OnEmbedEnable** function on all embeded libraries.\\ +-- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled. +-- +-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. +-- Use :Enable on the addon itself instead. +-- @param addon addon object to enable +function AceAddon:EnableAddon(addon) + if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end + if self.statuses[addon.name] or not addon.enabledState then return false end + + -- set the statuses first, before calling the OnEnable. this allows for Disabling of the addon in OnEnable. + self.statuses[addon.name] = true + + safecall(addon.OnEnable, addon) + + -- make sure we're still enabled before continueing + if self.statuses[addon.name] then + local embeds = self.embeds[addon] + for i = 1, #embeds do + local lib = LibStub:GetLibrary(embeds[i], true) + if lib then safecall(lib.OnEmbedEnable, lib, addon) end + end + + -- enable possible modules. + local modules = addon.orderedModules + for i = 1, #modules do + self:EnableAddon(modules[i]) + end + end + return self.statuses[addon.name] -- return true if we're disabled +end + +-- - Disable the addon +-- Note: This function is only used internally. +-- It will call the **OnDisable** function on the addon object (if present), +-- and the **OnEmbedDisable** function on all embeded libraries.\\ +-- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled. +-- +-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. +-- Use :Disable on the addon itself instead. +-- @param addon addon object to enable +function AceAddon:DisableAddon(addon) + if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end + if not self.statuses[addon.name] then return false end + + -- set statuses first before calling OnDisable, this allows for aborting the disable in OnDisable. + self.statuses[addon.name] = false + + safecall( addon.OnDisable, addon ) + + -- make sure we're still disabling... + if not self.statuses[addon.name] then + local embeds = self.embeds[addon] + for i = 1, #embeds do + local lib = LibStub:GetLibrary(embeds[i], true) + if lib then safecall(lib.OnEmbedDisable, lib, addon) end + end + -- disable possible modules. + local modules = addon.orderedModules + for i = 1, #modules do + self:DisableAddon(modules[i]) + end + end + + return not self.statuses[addon.name] -- return true if we're disabled +end + +--- Get an iterator over all registered addons. +-- @usage +-- -- Print a list of all installed AceAddon's +-- for name, addon in AceAddon:IterateAddons() do +-- print("Addon: " .. name) +-- end +function AceAddon:IterateAddons() return pairs(self.addons) end + +--- Get an iterator over the internal status registry. +-- @usage +-- -- Print a list of all enabled addons +-- for name, status in AceAddon:IterateAddonStatus() do +-- if status then +-- print("EnabledAddon: " .. name) +-- end +-- end +function AceAddon:IterateAddonStatus() return pairs(self.statuses) end + +-- Following Iterators are deprecated, and their addon specific versions should be used +-- e.g. addon:IterateEmbeds() instead of :IterateEmbedsOnAddon(addon) +function AceAddon:IterateEmbedsOnAddon(addon) return pairs(self.embeds[addon]) end +function AceAddon:IterateModulesOfAddon(addon) return pairs(addon.modules) end + +-- Event Handling +local function onEvent(this, event, arg1) + -- 2011-08-17 nevcairiel - ignore the load event of Blizzard_DebugTools, so a potential startup error isn't swallowed up + if (event == "ADDON_LOADED" and arg1 ~= "Blizzard_DebugTools") or event == "PLAYER_LOGIN" then + -- if a addon loads another addon, recursion could happen here, so we need to validate the table on every iteration + while(#AceAddon.initializequeue > 0) do + local addon = tremove(AceAddon.initializequeue, 1) + -- this might be an issue with recursion - TODO: validate + if event == "ADDON_LOADED" then addon.baseName = arg1 end + AceAddon:InitializeAddon(addon) + tinsert(AceAddon.enablequeue, addon) + end + + if IsLoggedIn() then + while(#AceAddon.enablequeue > 0) do + local addon = tremove(AceAddon.enablequeue, 1) + AceAddon:EnableAddon(addon) + end + end + end +end + +AceAddon.frame:RegisterEvent("ADDON_LOADED") +AceAddon.frame:RegisterEvent("PLAYER_LOGIN") +AceAddon.frame:SetScript("OnEvent", onEvent) + +-- upgrade embeded +for name, addon in pairs(AceAddon.addons) do + Embed(addon, true) +end + +-- 2010-10-27 nevcairiel - add new "orderedModules" table +if oldminor and oldminor < 10 then + for name, addon in pairs(AceAddon.addons) do + addon.orderedModules = {} + for module_name, module in pairs(addon.modules) do + tinsert(addon.orderedModules, module) + end + end +end diff --git a/Libs/AceAddon-3.0/AceAddon-3.0.xml b/Libs/AceAddon-3.0/AceAddon-3.0.xml new file mode 100644 index 0000000..e6ad639 --- /dev/null +++ b/Libs/AceAddon-3.0/AceAddon-3.0.xml @@ -0,0 +1,4 @@ + +