Thread Tools Display Modes
Prev Previous Post   Next Post Next
10-08-19, 11:04 AM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Testing LibAboutPanel-2.0, found bug

I'm dusting off my old project LibAboutPanel-2.0, which should work for both Classic and Retail. The testbed is a Classic addon.

However, I am getting a nil error, which makes sense as the table isn't created yet. But the table is nil, so the code should go onto fixing that, but it isn't, because it is nil, and round and round I go.

Error dump:
Lua Code:
  1. Date: 2019-10-08 10:53:13
  2. ID: 1
  3. Error occured in: Global
  4. Count: 1
  5. Message: ...pByZone\Libs\LibAboutPanel-2.0\LibAboutPanel-2.0.lua line 455:
  6.    attempt to index field 'aboutTable' (a nil value)
  7. Debug:
  8.    ...pByZone\Libs\LibAboutPanel-2.0\LibAboutPanel-2.0.lua:455: AboutOptionsTable()
  9.    RepByZone\Core.lua:32:
  10.       RepByZone\Core.lua:26
  11.    [C]: ?
  12.    ...ace\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:70:
  13.       ...ace\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:65
  14.    ...ace\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:498: InitializeAddon()
  15.    ...ace\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:613:
  16.       ...ace\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:605

LibAboutPanel-2.0 code follows. Line 455 reads:
Code:
local Table = self.aboutTable[addon]
and is located in the fuction AboutPanel:AboutOptionsTable(addon). I just can't spot what I've missed.
Lua Code:
  1. --[[
  2.     Whom is doing what with this library
  3.     $Author: myrroddin $
  4.     $URL: file:///media/cf-repositories/svn/wow/libaboutpanel-2-0/mainline/trunk/LibAboutPanel-2.0/LibAboutPanel-2.0.lua $
  5.     $Id: LibAboutPanel-2.0.lua 2 2016-09-11 06:20:19Z myrroddin $
  6.     $Header: file:///media/cf-repositories/svn/wow/libaboutpanel-2-0/mainline/trunk/LibAboutPanel-2.0/LibAboutPanel-2.0.lua 2 2016-09-11 06:20:19Z myrroddin $
  7.     @class file
  8.     @name LibAboutPanel-2.0.lua
  9.     @release $Id: LibAboutPanel-2.0.lua 2 2016-09-11 06:20:19Z myrroddin $
  10. ]]--
  11.  
  12. --- **LibAboutPanel-2.0** either creates an "About" panel in your AddOn's
  13. -- Interface/AddOns frame or within said AddOn's options table
  14. -- The word //About// will be localized, among other things, automatically
  15. -- API includes:
  16. -- * **CreateAboutPanel** which works like Ackis' LibAboutPanel
  17. -- * **AboutOptionsTable** which embeds the panel within AceConfig-3.0 options table
  18. --
  19. -- @usage
  20. -- function MyAddOn:OnInitialize()
  21. --     local options = {
  22. --         name = "MyAddOn",
  23. --         type = "group",
  24. --         args = {
  25. --             enableAddOn = {
  26. --                 order = 10,
  27. --                 name = ENABLE, -- use Blizzard's global string
  28. --                 type = "toggle",
  29. --                 get = function() return self.db.profile.enableAddOn end,
  30. --                 set = function(info, value)
  31. --                     self.db.profile.enableAddOn = value
  32. --                     if value then
  33. --                         self:OnEnable()
  34. --                     else
  35. --                         self:OnDisable()
  36. --                     end
  37. --                 end
  38. --             }
  39. --         }
  40. --     }
  41. --     -- support for LibAboutPanel-2.0
  42. --     options.args.aboutTab = self:AboutOptionsTable("MyAddOn")
  43. --     options.args.aboutTab.order = -1 -- -1 means "put it last"
  44.  
  45. --    -- Register your options with AceConfigRegistry
  46. --    LibStub("AceConfig-3.0"):RegisterOptionsTable("MyAddOn", options)
  47. -- end
  48.  
  49. local MAJOR, MINOR = "LibAboutPanel-2.0", tonumber("@project-revision@") or 1000
  50. assert(LibStub, MAJOR .. " requires LibStub")
  51. local AboutPanel = LibStub:NewLibrary(MAJOR, MINOR)
  52. if not AboutPanel then return end  -- no upgrade necessary
  53.  
  54. AboutPanel.embeds = AboutPanel.embeds or {} -- table containing objects AboutPanel is embedded in.
  55. AboutPanel.aboutTable = AboutPanel.aboutTable or {} -- tables for
  56. AboutPanel.aboutFrame = AboutPanel.aboutFrame or {}
  57.  
  58. -- Lua APIs
  59. local setmetatable, tostring, rawset, pairs = setmetatable, tostring, rawset, pairs
  60. -- WoW APIs
  61. local GetLocale, GetAddOnMetadata, CreateFrame = GetLocale, GetAddOnMetadata, CreateFrame
  62.  
  63. -- localization ---------------------------------
  64. local L = setmetatable({}, {
  65.     __index = function(tab, key)
  66.         local value = tostring(key)
  67.         rawset(tab, key, value)
  68.         return value
  69.     end
  70. })
  71.  
  72. local locale = GetLocale()
  73. if locale == "koKR" then
  74.     L["About"] = "대하여"
  75.     L["Click and press Ctrl-C to copy"] = "클릭 후 Ctrl-C 복사"
  76.     L["Author"] = "저작자"
  77.     L["Category"] = "분류"
  78.     L["Credits"] = "공로자"
  79.     L["Date"] = "날짜"
  80.     L["Email"] = "전자 우편"
  81.     L["License"] = "라이센스"
  82.     L["Version"] = "버전"
  83.     L["Website"] = "웹 사이트"
  84. -- L["All Rights Reserved"] = ""
  85. -- L["Localizations"] = ""
  86. -- L["on the %s realm"] = ""
  87. -- L["Repository"] = ""
  88. elseif locale == "frFR" then
  89.     L["About"] = "à propos de"
  90.     L["Category"] = "Catégorie"
  91.     L["Author"] = "Auteur"
  92.     L["Date"] = "Date"
  93.     L["Email"] = "E-mail"
  94.     L["Version"] = "Version"
  95.     L["Website"] = "Site web"
  96. -- L["All Rights Reserved"] = ""
  97. -- L["Click and press Ctrl-C to copy"] = ""
  98. -- L["Credits"] = ""
  99. -- L["License"] = ""
  100. -- L["Localizations"] = ""
  101. -- L["on the %s realm"] = ""
  102. -- L["Repository"] = ""
  103. elseif locale == "deDE" then
  104.     L["About"] = "Über"
  105.     L["Author"] = "Autor"
  106.     L["Category"] = "Kategorie"
  107.     L["Click and press Ctrl-C to copy"] = "Klicken und Strg-C drücken zum kopieren."
  108.     L["Credits"] = "Ehren"
  109.     L["Date"] = "Datum"
  110.     L["Email"] = "E-Mail"
  111.     L["License"] = "Lizenz"
  112.     L["Localizations"] = "Sprachen"
  113.     L["Version"] = "Version"
  114.     L["Website"] = "Webseite"
  115. -- L["All Rights Reserved"] = ""
  116. -- L["on the %s realm"] = ""
  117. -- L["Repository"] = ""
  118. elseif locale == "ruRU" then
  119.     L["About"] = "Об аддоне"
  120.     L["All Rights Reserved"] = "Все права сохранены"
  121.     L["Author"] = "Автор"
  122.     L["Category"] = "Категория"
  123.     L["Click and press Ctrl-C to copy"] = "Щелкните и нажмите Ctrl-C для копирования"
  124.     L["Date"] = "Дата"
  125.     L["Email"] = "Почта"
  126.     L["License"] = "Лицензия"
  127.     L["Localizations"] = "Локализация"
  128.     L["on the %s realm"] = "с сервера %s"
  129.     L["Repository"] = "Репозиторий"
  130.     L["Version"] = "Версия"
  131.     L["Website"] = "Сайт"
  132. --L["Credits"] = ""
  133. elseif locale == "zhTW" then
  134.     L["About"] = "日期"
  135.     L["Category"] = "類別"
  136.     L["Click and press Ctrl-C to copy"] = "左鍵點擊並按下 Ctrl-C 以複製字串"
  137.     L["Date"] = "日期"
  138.     L["Author"] = "作者"
  139.     L["Credits"] = "特別感謝"
  140.     L["Email"] = "電子郵件"
  141.     L["License"] = "版權"
  142.     L["Version"] = "版本"
  143.     L["Website"] = "網站"
  144. -- L["All Rights Reserved"] = ""
  145. -- L["Localizations"] = ""
  146. -- L["on the %s realm"] = ""
  147. -- L["Repository"] = ""
  148. elseif locale == "zhCN" then
  149.     L["About"] = "关于"
  150.     L["Category"] = "分类"
  151.     L["Click and press Ctrl-C to copy"] = "点击并 Ctrl-C 复制"
  152.     L["Date"] = "日期"
  153.     L["Author"] = "作者"
  154.     L["Email"] = "电子邮件"
  155.     L["Version"] = "版本"
  156.     L["Website"] = "网站"
  157. -- L["All Rights Reserved"] = ""
  158. -- L["Credits"] = ""
  159. -- L["License"] = ""
  160. -- L["Localizations"] = ""
  161. -- L["on the %s realm"] = ""
  162. -- L["Repository"] = ""
  163. elseif locale == "itIT" then
  164. -- L["About"] = ""
  165. -- L["All Rights Reserved"] = ""
  166. -- L["Author"] = ""
  167. -- L["Click and press Ctrl-C to copy"] = ""
  168. -- L["Credits"] = ""
  169. -- L["Email"] = ""
  170. -- L["License"] = ""
  171. -- L["Localizations"] = ""
  172. -- L["Repository"] = ""
  173. -- L["on the %s realm"] = ""
  174. -- L["Version"] = ""
  175. -- L["Website"] = ""
  176. elseif locale == "ptBR" then
  177. -- L["About"] = ""
  178. -- L["All Rights Reserved"] = ""
  179. -- L["Author"] = ""
  180. -- L["Click and press Ctrl-C to copy"] = ""
  181. -- L["Credits"] = ""
  182. -- L["Email"] = ""
  183. -- L["License"] = ""
  184. -- L["Localizations"] = ""
  185. -- L["Repository"] = ""
  186. -- L["on the %s realm"] = ""
  187. -- L["Version"] = ""
  188. -- L["Website"] = ""
  189. elseif locale == "esES" or locale == "esMX" then
  190.     L["About"] = "Sobre"
  191.     L["Author"] = "Autor"
  192.     L["Category"] = "Categoría"
  193.     L["Click and press Ctrl-C to copy"] = "Clic y pulse Ctrl-C para copiar."
  194.     L["Credits"] = "Créditos"
  195.     L["Date"] = "Fecha"
  196.     L["Email"] = "Email"
  197.     L["License"] = "Licencia"
  198.     L["Localizations"] = "Idiomas"
  199.     L["Version"] = "Versión"
  200.     L["Website"] = "Sitio web"
  201. -- L["All Rights Reserved"] = ""
  202. -- L["on the %s realm"] = ""
  203. -- L["Repository"] = ""
  204. end
  205.  
  206. -- handy fuction to create Title Case -----------
  207. local function TitleCase(str)
  208.     str = str:gsub("(%a)(%a+)", function(a, b) return a:upper()..b:lower() end)
  209.     return str
  210. end
  211.  
  212. local function GetTitle(addon)
  213.     local title = "Title"
  214.     if locale ~= "enUS" then
  215.         title = title .. "-" .. locale
  216.     end
  217.     return GetAddOnMetadata(addon, title) or GetAddOnMetadata(addon, "Title")
  218. end
  219.  
  220. local function GetNotes(addon)
  221.     local notes = "Notes"
  222.     if locale ~= "enUS" then
  223.         notes = notes .. "-" .. locale
  224.     end
  225.     return GetAddOnMetadata(addon, notes) or GetAddOnMetadata(addon, "Notes")
  226. end
  227.  
  228. local function GetAddOnDate(addon)
  229.     local date = GetAddOnMetadata(addon, "X-Date") or GetAddOnMetadata(addon, "X-ReleaseDate")
  230.     if not date then return end
  231.  
  232.     date = date:gsub("%$Date: (.-) %$", "%1")
  233.     date = date:gsub("%$LastChangedDate: (.-) %$", "%1")
  234.     return date
  235. end
  236.  
  237. local function GetAuthor(addon)
  238.     local author = GetAddOnMetadata(addon, "Author")
  239.     if not author then return end
  240.  
  241.     author = TitleCase(author)
  242.     local server = GetAddOnMetadata(addon, "X-Author-Server")
  243.     local guild = GetAddOnMetadata(addon, "X-Author-Guild")
  244.     local faction = GetAddOnMetadata(addon, "X-Author-Faction")
  245.  
  246.     if server then
  247.         server = TitleCase(server)
  248.         author = author .. " " .. L["on the %s realm"]:format(server) .. "."
  249.     end
  250.     if guild then
  251.     author = author .. " " .. "<" .. guild .. ">"
  252.     end
  253.     if faction then
  254.         faction = TitleCase(faction)
  255.         faction = faction:gsub("Alliance", FACTION_ALLIANCE)
  256.         faction = faction:gsub("Horde", FACTION_HORDE)
  257.         author = author .. " " .. "(" .. faction .. ")"
  258.     end
  259.     return author
  260. end
  261.  
  262. local function GetVersion(addon)
  263.     local version = GetAddOnMetadata(addon, "Version")
  264.     if not version then return end
  265.  
  266.     version = version:gsub("%.?%$Revision: (%d+) %$", " -rev.".."%1")
  267.     version = version:gsub("%.?%$Rev: (%d+) %$", " -rev.".."%1")
  268.     version = version:gsub("%.?%$LastChangedRevision: (%d+) %$", " -rev.".."%1")
  269.  
  270.     -- replace repository keywords
  271.     version = version:gsub("r2", L["Repository"]) -- Curse
  272.     version = version:gsub("wowi:revision", L["Repository"]) -- WoWInterface
  273.  
  274.     local revision = GetAddOnMetadata(addon, "X-Project-Revision")
  275.     version = revision and version.." -rev."..revision or version
  276.     return version
  277. end
  278.  
  279. local function GetCategory(addon)
  280.     return GetAddOnMetadata(addon, "X-Category")
  281. end
  282.  
  283. local function GetLicense(addon)
  284.     local license = GetAddOnMetadata(addon, "X-License")
  285.     if not license then return end
  286.  
  287.     license = license:gsub("[cC]opyright", "©")
  288.     license = license:gsub("%([cC]%)", "©")
  289.     license = license:gsub("[aA]ll [rR]ights [rR]eserved", L["All Rights Reserved"])
  290.     return license
  291. end
  292.  
  293. local function GetLocalizations(addon)
  294.     return GetAddOnMetadata(addon, "X-Localizations")
  295. end
  296.  
  297. local function GetCredits(addon)
  298.     return GetAddOnMetadata(addon, "X-Credits")
  299. end
  300.  
  301. local function GetWebsite(addon)
  302.     local websites = GetAddOnMetadata(addon, "X-Website")
  303.     if not websites then return end
  304.  
  305.     return "|cff77ccff"..websites:gsub("https?://", "")
  306. end
  307.  
  308. local function GetEmail(addon)
  309.     local email = GetAddOnMetadata(addon, "X-Email") or GetAddOnMetadata(addon, "Email") or GetAddOnMetadata(addon, "eMail")
  310.     if not email then return end
  311.  
  312.     return "|cff77ccff"..GetAddOnMetadata(addon, "X-Email")
  313. end
  314.  
  315. -- LibAboutPanel stuff --------------------------
  316. local editbox = CreateFrame("EditBox", nil, nil, "InputBoxTemplate")
  317. editbox:Hide()
  318. editbox:SetFontObject("GameFontHighlightSmall")
  319. AboutPanel.editbox = editbox
  320.  
  321. editbox:SetScript("OnEscapePressed", editbox.Hide)
  322. editbox:SetScript("OnEnterPressed", editbox.Hide)
  323. editbox:SetScript("OnEditFocusLost", editbox.Hide)
  324. editbox:SetScript("OnEditFocusGained", editbox.HighlightText)
  325. editbox:SetScript("OnTextChanged", function(self)
  326.     self:SetText(self:GetParent().value)
  327.     self:HighlightText()
  328. end)
  329.  
  330. local function OpenEditbox(self, ...)
  331.     editbox:SetParent(self)
  332.     editbox:SetAllPoints(self)
  333.     editbox:SetText(self.value)
  334.     editbox:Show()
  335. end
  336.  
  337. local function HideTooltip()
  338.     GameTooltip:Hide()
  339. end
  340.  
  341. local function ShowTooltip(self)
  342.     GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT")
  343.     GameTooltip:SetText(L["Click and press Ctrl-C to copy"])
  344. end
  345.  
  346. --- Create a new About panel
  347. -- @name //addon//:CreateAboutPanel
  348. -- @paramsig AddOn[, parent]
  349. -- @param AddOn name of which you are attaching the panel. String
  350. -- @param parent AddOn name in Interface Options. String or nil
  351. -- If parent is provided, panel will be under [+]
  352. -- otherwise the panel will be a normal AddOn category
  353. -- @return frame To do as you wish
  354. -- @usage local aboutFrame = MyAddOn:CreateAboutPanel("MyAddOn", "MyAddOn")
  355. -- -- OR
  356. -- MyAddOn:CreateAboutPanel("MyAddOn", "MyAddOn")
  357. function AboutPanel:CreateAboutPanel(addon, parent)
  358.     addon = addon:gsub(" ", "") -- Remove spaces from AddOn because GetMetadata doesn't like those
  359.     local addon = parent or addon
  360.     local frame = self.aboutFrame[addon]
  361.  
  362.     if not frame then
  363.         frame = CreateFrame("Frame", addon.."AboutPanel", UIParent)
  364.  
  365.         local title = GetTitle(addon)
  366.         local title_str = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
  367.         title_str:SetPoint("TOPLEFT", 16, -16)
  368.         title_str:SetText((parent and title or addon) .. " - " .. L["About"])
  369.  
  370.         local notes = GetNotes(addon)
  371.         local notes_str
  372.         if notes then
  373.             notes_str = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
  374.             notes_str:SetHeight(32)
  375.             notes_str:SetPoint("TOPLEFT", title_str, "BOTTOMLEFT", 0, -8)
  376.             notes_str:SetPoint("RIGHT", frame, -32, 0)
  377.             notes_str:SetNonSpaceWrap(true)
  378.             notes_str:SetJustifyH("LEFT")
  379.             notes_str:SetJustifyV("TOP")
  380.             notes_str:SetText(GetNotes(addon))
  381.         end
  382.  
  383.         local i, title, detail = 0, {}, {}
  384.         local function SetAboutInfo(field, text, editbox)
  385.             i = i + 1
  386.             title[i] = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
  387.             if i == 1 then
  388.                 title[i]:SetPoint("TOPLEFT", notes and notes_str or title_str, "BOTTOMLEFT", -2, -12)
  389.             else
  390.                 title[i]:SetPoint("TOPLEFT", title[i-1], "BOTTOMLEFT", 0, -10)
  391.             end
  392.             title[i]:SetWidth(80)
  393.             title[i]:SetJustifyH("RIGHT")
  394.             title[i]:SetJustifyV("TOP")
  395.             title[i]:SetText(field)
  396.  
  397.             detail[i] = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
  398.             detail[i]:SetPoint("TOPLEFT", title[i], "TOPRIGHT", 4, 0)
  399.             detail[i]:SetPoint("RIGHT", frame, -16, 0)
  400.             detail[i]:SetJustifyH("LEFT")
  401.             detail[i]:SetJustifyV("TOP")
  402.             detail[i]:SetText(text)
  403.  
  404.             if editbox then
  405.                 local button = CreateFrame("Button", nil, frame)
  406.                 button:SetAllPoints(detail[i])
  407.                 button.value = text
  408.                 button:SetScript("OnClick", OpenEditbox)
  409.                 button:SetScript("OnEnter", ShowTooltip)
  410.                 button:SetScript("OnLeave", HideTooltip)
  411.             end
  412.         end
  413.  
  414.         local date = GetAddOnDate(addon)
  415.         if date then SetAboutInfo(L["Date"], date) end
  416.         local version = GetVersion(addon)
  417.         if version then SetAboutInfo(L["Version"], version) end
  418.         local author = GetAuthor(addon)
  419.         if author then SetAboutInfo(L["Author"], author) end
  420.         local category = GetCategory(addon)
  421.         if category then SetAboutInfo(L["Category"], category) end
  422.         local license = GetLicense(addon)
  423.         if license then SetAboutInfo(L["License"], license) end
  424.         local credits = GetCredits(addon)
  425.         if credits then SetAboutInfo(L["Credits"], credits) end
  426.         local email = GetEmail(addon)
  427.         if email then SetAboutInfo(L["Email"], email, true) end
  428.         local website = GetWebsite(addon)
  429.         if website then SetAboutInfo(L["Website"], website, true) end
  430.         local localizations = GetLocalizations(addon)
  431.         if localizations then SetAboutInfo(L["Localizations"], localizations) end
  432.  
  433.         frame.name = not parent and addon or L["About"]
  434.         frame.parent = parent
  435.         InterfaceOptions_AddCategory(frame)
  436.         self.aboutFrame[addon] = frame
  437.     end
  438.  
  439.     return frame
  440. end
  441.  
  442. --- Creates a table of an AddOn's ToC fields
  443. -- see [url]http://www.wowace.com/addons/ace3/pages/api/ace-config-3-0/[/url]
  444. -- @name //addon//:AboutOptionsTable
  445. -- @param AddOn name string whose ToC you want parsed
  446. -- @return aboutTable suitable for use with AceConfig-3.0
  447. -- @usage -- assuming options is your top-level table
  448. -- local options = {} -- put your regular stuff here
  449. -- options.args.aboutTable = MyAddOn:AboutOptionsTable("MyAddOn")
  450. -- options.args.aboutTable.order = -1 -- use any number in the hierarchy. -1 means "put it last"
  451. -- LibStub("AceConfig-3.0"):RegisterOptionsTable("MyAddOn", options)
  452. function AboutPanel:AboutOptionsTable(addon)
  453.     assert(LibStub("AceConfig-3.0"), "LibAboutPanel-2.0: API 'AboutOptionsTable' requires AceConfig-3.0", 2)
  454.     addon = addon:gsub(" ", "") -- Remove spaces from AddOn because GetMetadata doesn't like those
  455.     local Table = self.aboutTable[addon]
  456.     if not Table then
  457.         Table = {
  458.             name = L["About"],
  459.             type = "group",
  460.             args = {
  461.                 title = {
  462.                     order = 1,
  463.                     name = "|cffe6cc80" .. GetTitle(addon) .. "|r",
  464.                     type = "description",
  465.                     fontSize = "large",
  466.                 },
  467.             },
  468.         }
  469.         local notes = GetNotes(addon)
  470.         if notes then
  471.             Table.args.blank = {
  472.                 order = 2,
  473.                 name = "",
  474.                 type = "description",
  475.             }
  476.             Table.args.notes = {
  477.                 order = 3,
  478.                 name = notes,
  479.                 type = "description",
  480.                 fontSize = "medium",
  481.             }
  482.         end
  483.         Table.args.blank2 = {
  484.             order = 4,
  485.             name = "\n",
  486.             type = "description",
  487.         }
  488.         local date = GetAddOnDate(addon)
  489.         if date then
  490.             Table.args.date = {
  491.                 order = 5,
  492.                 name = "|cffe6cc80" .. L["Date"] .. ": |r" .. date,
  493.                 type = "description",
  494.             }
  495.         end
  496.         local version = GetVersion(addon)
  497.         if version then
  498.             Table.args.version = {
  499.                 order = 6,
  500.                 name = "|cffe6cc80" .. L["Version"] .. ": |r" .. version,
  501.                 type = "description",
  502.             }
  503.         end
  504.         local author = GetAuthor(addon)
  505.         if author then
  506.             Table.args.author = {
  507.                 order = 7,
  508.                 name = "|cffe6cc80" .. L["Author"] .. ": |r" .. author,
  509.                 type = "description",
  510.             }
  511.         end
  512.         local category = GetCategory(addon)
  513.         if category then
  514.             Table.args.category = {
  515.                 order = 8,
  516.                 name = "|cffe6cc80" .. L["Category"] .. ": |r" .. category,
  517.                 type = "description",
  518.             }
  519.         end
  520.         local license = GetLicense(addon)
  521.         if license then
  522.             Table.args.license = {
  523.                 order = 9,
  524.                 name = "|cffe6cc80" .. L["License"] .. ": |r" .. license,
  525.                 type = "description",
  526.             }
  527.         end
  528.         local credits = GetCredits(addon)
  529.         if credits then
  530.             Table.args.credits = {
  531.                 order = 10,
  532.                 name = "|cffe6cc80" .. L["Credits"] .. ": |r" .. credits,
  533.                 type = "description",
  534.             }
  535.         end
  536.         local email = GetEmail(addon)
  537.         if email then
  538.             Table.args.email = {
  539.                 order = 11,
  540.                 name = "|cffe6cc80" .. L["Email"] .. ": |r",
  541.                 desc = L["Click and press Ctrl-C to copy"],
  542.                 type = "input",
  543.                 width = "full",
  544.                 get = function() return email end,
  545.             }
  546.         end
  547.         local website = GetWebsite(addon)
  548.         if website then
  549.             Table.args.website = {
  550.                 order = 12,
  551.                 name = "|cffe6cc80" .. L["Website"] .. ": |r",
  552.                 desc = L["Click and press Ctrl-C to copy"],
  553.                 type = "input",
  554.                 width = "full",
  555.                 get = function() return website end,
  556.             }
  557.         end
  558.         local localizations = GetLocalizations(addon)
  559.         if localizations then
  560.             Table.args.localizations = {
  561.                 order = 13,
  562.                 name = "|cffe6cc80" .. L["Localizations"] .. ": |r" .. localizations,
  563.                 type = "description",
  564.             }
  565.         end
  566.         self.aboutTable[addon] = Table
  567.     end
  568.     return Table
  569. end
  570.  
  571. -- ---------------------------------------------------------------------
  572. -- Embed handling
  573.  
  574. local mixins = {
  575.     "CreateAboutPanel",
  576.     "AboutOptionsTable"
  577. }
  578.  
  579. -- AboutPanel AceConsole into the target object making the functions from the mixins list available on target:..
  580. -- So you can call LibStub("LibAboutPanel-2.0"):Embed(myAddOn)
  581. -- @param target AddOn table in which to embed
  582. -- @usage
  583. -- local addonname, AddOn = ...
  584. -- LibStub("LibAboutPanel-2.0"):Embed(AddOn)
  585. -- -- **OR**, if using Ace3
  586. -- -- you do not explicitly call :Embed
  587. -- local MyAddOn = LibStub("AceAddon-3.0"):NewAddon("MyAddOn", "LibAboutPanel-2.0")
  588. function AboutPanel:Embed(target)
  589.     for k, v in pairs(mixins) do
  590.         target[v] = self[v]
  591.     end
  592.     self.embeds[target] = true
  593.     return target
  594. end
  595.  
  596. --- Upgrade our old embeded
  597. for addon in pairs(AboutPanel.embeds) do
  598.     AboutPanel:Embed(addon)
  599. end
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Testing LibAboutPanel-2.0, found bug

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off