View Single Post
11-02-18, 10:25 PM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Ah ha. Here's my entire code. I'll load into game shortly to test. After line adjustments, I am trying to populate line 186 with the values contained in AddOnList. I don't need a table inside a table. I'm not sure if the do/end loop is necessary; I just put it there in case.
Lua Code:
  1. local Aardvark = LibStub("AceAddon-3.0"):GetAddon("Aardvark")
  2. local L = LibStub("AceLocale-3.0"):GetLocale("Aardvark", false)
  3. local ldbIcon = LibStub("LibDBIcon-1.0")
  4.  
  5. local options = nil
  6. local db
  7. local exempt = {
  8.     -- always allow these addons to print to chat
  9.     ["!Aardvark"] = true,
  10.     ["!Swatter"] = true,
  11.     ["Ace3"] = true,
  12.     ["BugSack"] = true,
  13.     ["Bugger"] = true
  14. }
  15. local OptionsHandler = {} -- local function to this file
  16. do
  17.     local AddOnList = {}
  18.     for i = 1, GetNumAddOns() do
  19.         local folderName, title = GetAddOnInfo(i)
  20.         if not exempt[folderName] then
  21.             table.insert(AddOnList, {name = title})
  22.         end
  23.     end
  24.     table.sort(AddOnList, function(a, b) -- sort alphabetically
  25.         return a.name > b.name
  26.     end)
  27. end
  28.  
  29. function Aardvark:GetOptions()
  30.     db = db or self.db.global
  31.     options = options or {
  32.         type = "group",
  33.         childGroups = "tab",
  34.         name = Aardvark.Name,
  35.         desc = Aardvark.Notes,
  36.         arg = "!Aardvark",
  37.         args = {
  38.             general = {
  39.                 order = 10,
  40.                 name = COMPACT_UNIT_FRAME_PROFILE_SUBTYPE_ALL,
  41.                 type = "group",
  42.                 args = {
  43.                     enable = {
  44.                         order = 10,
  45.                         name = ENABLE,
  46.                         desc = L["Toggle Aardvark on or off."],
  47.                         type = "toggle",
  48.                         get = function() return db.enabled end,
  49.                         set = function(info, value)
  50.                             db.enabled = value
  51.                             if value then
  52.                                 self:OnEnable()
  53.                             else
  54.                                 self:OnDisable()
  55.                             end
  56.                         end
  57.                     }, -- end enabled
  58.                     instance = {
  59.                         order = 20,
  60.                         name = L["Instance Chat"],
  61.                         desc = L["Leave General chat channel when you enter an instance, rejoin when you leave."],
  62.                         type = "toggle",
  63.                         get = function() return db.instance end,
  64.                         set = function(info, value)
  65.                             db.instance = value
  66.                             self:PLAYER_ENTERING_WORLD()
  67.                         end
  68.                     }, -- end instance General join/leave
  69.                     cleanChat = {
  70.                         order = 30,
  71.                         name = L["Clear Chat"],
  72.                         desc = L["Clear the chat windows when first logging in."],
  73.                         type = "toggle",
  74.                         get = function() return db.cleanChat end,
  75.                         set = function(info, value)
  76.                             db.cleanChat = value
  77.                         end
  78.                     }, -- end login clean chat
  79.                     saveGMOTD = {
  80.                         order = 40,
  81.                         name = GUILD_MOTD_LABEL2,
  82.                         desc = L["Restores guild message of the day after clearing chat when first logging in."],
  83.                         type = "toggle",
  84.                         disabled = function() return not db.cleanChat end,
  85.                         get = function() return db.saveGMOTD end,
  86.                         set = function(info, value)
  87.                             db.saveGMOTD = value
  88.                         end
  89.                     }, -- end GMOTD save
  90.                     cleanNow = {
  91.                         order = 50,
  92.                         name = L["Clean Chat Now"],
  93.                         type = "execute",
  94.                         width = "full",
  95.                         func = function() self:ClearChat() end,
  96.                         disabled = function() return not self.db.global.enabled end
  97.                     }, -- end clean now button
  98.                     hideLDBIcon = {
  99.                         order = 60,
  100.                         name = L["Hide Minimap Button"],
  101.                         desc = L["Toggle hiding the button"],
  102.                         type = "toggle",
  103.                         get = function() return db.minimap.hide end,
  104.                         set = function(info, value)
  105.                             db.minimap.hide = value
  106.                             if value then
  107.                                 ldbIcon:Hide("Aardvark")
  108.                             else
  109.                                 ldbIcon:Show("Aardvark")
  110.                             end
  111.                         end
  112.                     }, -- end toggle Broker button
  113.                     lockLDBIcon = {
  114.                         order = 70,
  115.                         name = L["Lock Button"],
  116.                         desc = L["Lock the button so it cannot be moved."],
  117.                         type = "toggle",
  118.                         get = function() return db.minimap.lock end,
  119.                         set = function(info, value)
  120.                             db.minimap.lock = value
  121.                             if value then
  122.                                 ldbIcon:Lock("Aardvark")
  123.                             else
  124.                                 ldbIcon:Unlock("Aardvark")
  125.                             end
  126.                         end
  127.                     }, -- end button lock
  128.                     minimapPos = {
  129.                         order = 80,
  130.                         name = L["Rotation"],
  131.                         desc = L["Rotate the button around the minimap."],
  132.                         type = "range",
  133.                         get = function() return db.minimap.minimapPos end,
  134.                         set = function(info, value)
  135.                             db.minimap.minimapPos = value
  136.                         end,
  137.                         disabled = function() return db.minimap.lock end,
  138.                         min = 1,
  139.                         max = 355,
  140.                         step = 1,
  141.                         bigStep = 5
  142.                     }, -- end of minimapPos
  143.                     radius = {
  144.                         order = 90,
  145.                         name = L["Range From Center"],
  146.                         desc = L["Move the button closer or further from the center of the minimap."],
  147.                         type = "range",
  148.                         get = function() return db.minimap.radius end,
  149.                         set = function(info, value)
  150.                             db.minimap.radius = value
  151.                         end,
  152.                         disabled = function() return db.minimap.lock end,
  153.                         min = 0,
  154.                         max = 160,
  155.                         step = 1,
  156.                         bigStep = 5
  157.                     } -- end of radius
  158.                 }
  159.             }, -- end of general options
  160.             addons = {
  161.                 order = 20,
  162.                 name = ADDONS,
  163.                 desc = L["Toggle AddOns' ability to send messages to the chat frame."],
  164.                 type = "group",
  165.                 handler = OptionsHandler,
  166.                 args = {
  167.                     selectAll = {
  168.                         order = 1, -- want it first
  169.                         name = ENABLE_ALL_ADDONS,
  170.                         desc = L["Enable all AddOns to print to chat."],
  171.                         type = "execute",
  172.                         func = "SelectAll",
  173.                     }, -- end of select all
  174.                     selectNone = {
  175.                         order = 2, -- want it second
  176.                         name = DISABLE_ALL_ADDONS,
  177.                         desc = L["Disable all AddOns from printing to chat."],
  178.                         type = "execute",
  179.                         func = "SelectNone"
  180.                     }, -- end of selecting no addons
  181.                     installedAddOns = {
  182.                         order = 3, -- want this third
  183.                         name = L["Selected AddOns"],
  184.                         desc = L["Toggle these off to prevent individual AddOns from printing to chat."],
  185.                         type = "multiselect",
  186.                         values = AddOnList,
  187.                         get = GetState,
  188.                         set = SetState
  189.                     } -- end of installed addons
  190.                 }
  191.             } -- end of addons section
  192.         }
  193.     }
  194.     return options
  195. end
  196.  
  197. function OptionsHandler:SelectAll(info)
  198. end
  199.  
  200. function OptionsHandler:selectNone(info)
  201. end
  202.  
  203. function OptionsHandler:SetState(info, index, state)
  204. end
  205.  
  206. function OptionsHandler:GetState(info, index)
  207. end
  Reply With Quote