Merge commit '3127f5'

Sasky [06-21-14 - 12:43]
Merge commit '3127f5'

Conflicts:
	LAddMin.lua
	LAddMin.txt

Straight merge - still 2 menu generation functions
Filename
LAddMin.lua
LAddMin.txt
LibAddonMenu-1.0.txt
diff --git a/LAddMin.lua b/LAddMin.lua
index 36e7eb8..73fda7e 100644
--- a/LAddMin.lua
+++ b/LAddMin.lua
@@ -34,243 +34,304 @@ local LAM1 = LibStub("LibAddonMenu-1.0")
 local LAM2 = LibStub("LibAddonMenu-2.0")

 -------------------------------------------------------------------------------
--- Library replacement --------------------------------------------------------
+-- Local variables ------------------------------------------------------------
 -------------------------------------------------------------------------------
-local FAKE_LAM1 = setmetatable ({}, { __index = LAM1 })
-LibStub.libs["LibAddonMenu-1.0"] = FAKE_LAM1
-LibStub.minors["LibAddonMenu-1.0"] = 999
-
-local settingsTable = {}
+local sv
 local panelIDs = {}
+local settingsTable = {}
+local invalidAddons = LAddMinCompatability

-local knownAddons = LAddMinCompatability
+-- local missedPanelIDs = {}
+-- local lastID = 1000

-LAddMinUpconvertSettings = ZO_SavedVars:NewAccountWide('LAddMin_ConversionList', 2, "list", { cfg = {}})

 -------------------------------------------------------------------------------
--- FAKE_LAM1 functions --------------------------------------------------------
+-- Library replacement --------------------------------------------------------
 -------------------------------------------------------------------------------
+
+--LAM 1.0 to 2.0 interface
+FAKE_LAM1 = setmetatable ({}, { __index = LAM1 })
+LibStub.libs["LibAddonMenu-1.0"] = FAKE_LAM1
+LibStub.minors["LibAddonMenu-1.0"] = 999
 -- LAM1:CreateControlPanel(controlPanelID, controlPanelName)
 function FAKE_LAM1:CreateControlPanel(controlPanelID, controlPanelName)
    local name = controlPanelName:gsub("|[cC]%w%w%w%w%w%w",""):gsub("|[rR]","")

-   --Not in settings -- new addon
-   if LAddMinUpconvertSettings.cfg[name] == nil then
-       --Either known bad or unknown. Set to not convert
-       if not knownAddons[name] then
-         LAddMinUpconvertSettings.cfg[name] = false
+   if sv == nil then
+      if not invalidAddons[name] then
+         invalidAddons[name] = false
          return LAM1:CreateControlPanel(controlPanelID, name)
-       end
-       --Known good. Default to convert
-       LAddMinUpconvertSettings.cfg[name] = true
+      end
    else
-       --Use saved value
-       if not LAddMinUpconvertSettings.cfg[name] then
+      if not sv.enabled[name] then
+         if sv.enabled[name] == nil then
+            sv.enabled[name] = false
+         end
          return LAM1:CreateControlPanel(controlPanelID, name)
-       end
+      end
    end

-   if panelIDs[name] ~= nil then
-      return panelIDs[name]
-   end
+      if panelIDs[name] ~= nil then
+         return panelIDs[name]
+      end

-   local panelID = #settingsTable + 1001
-   panelIDs[name] = panelID
+      local panelID = #settingsTable + 1001
+      panelIDs[name] = panelID

-   local panelTable = {
-      name = name,
-      displayName = controlPanelName,
-      controls = {},
-   }
+      local panelTable = {
+         name = name,
+         displayName = controlPanelName,
+         controls = {},
+      }

-   settingsTable[panelID - 1000] = panelTable
+      settingsTable[panelID - 1000] = panelTable

-   LAM2:RegisterAddonPanel(controlPanelID, panelTable)
-   LAM2:RegisterOptionControls(controlPanelID, panelTable.controls)
+      LAM2:RegisterAddonPanel(controlPanelID, panelTable)
+      LAM2:RegisterOptionControls(controlPanelID, panelTable.controls)

-   return panelID
-end
--- LAM1:AddHeader(panelID, controlName, text)
-function FAKE_LAM1:AddHeader(panelID, controlName, text)
-   if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
-      return LAM1:AddHeader(panelID, controlName, text)
+      return panelID
    end
-
-   local controlTable = {
-      type = "header",
-      name = text,
-      reference = controlName,
-   }
-
-   local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
-   table.insert(tab, controlTable)
-
-   return tab[#tab]
-end
--- LAM1:AddSlider(panelID, controlName, text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText)
-function FAKE_LAM1:AddSlider(panelID, controlName, text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText)
-   if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
-      return LAM1:AddSlider(panelID, controlName, text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText)
+   -- LAM1:AddHeader(panelID, controlName, text)
+   function FAKE_LAM1:AddHeader(panelID, controlName, text)
+      if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
+         return LAM1:AddHeader(panelID, controlName, text)
+      end
+
+      local controlTable = {
+         type = "header",
+         name = text,
+         reference = controlName,
+      }
+
+      local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
+      table.insert(tab, controlTable)
+
+      return tab[#tab]
    end
-
-   local controlTable = {
-      type = "slider",
-      name = text,
-      tooltip = tooltip,
-      min = minValue,
-      max = maxValue,
-      step = step,
-      getFunc = getFunc,
-      setFunc = setFunc,
-      warning = warningText,
-      reference = controlName,
-   }
-
-   local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
-   table.insert(tab, controlTable)
-
-   return tab[#tab]
-end
--- LAM1:AddDropdown(panelID, controlName, text, tooltip, validChoices, getFunc, setFunc, warning, warningText)
-function FAKE_LAM1:AddDropdown(panelID, controlName, text, tooltip, validChoices, getFunc, setFunc, warning, warningText)
-   if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
-      return LAM1:AddDropdown(panelID, controlName, text, tooltip, validChoices, getFunc, setFunc, warning, warningText)
+   -- LAM1:AddSlider(panelID, controlName, text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText)
+   function FAKE_LAM1:AddSlider(panelID, controlName, text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText)
+      if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
+         return LAM1:AddSlider(panelID, controlName, text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText)
+      end
+
+      local controlTable = {
+         type = "slider",
+         name = text,
+         tooltip = tooltip,
+         min = minValue,
+         max = maxValue,
+         step = step,
+         getFunc = getFunc,
+         setFunc = setFunc,
+         warning = warningText,
+         reference = controlName,
+      }
+
+      local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
+      table.insert(tab, controlTable)
+
+      return tab[#tab]
    end
-
-   local controlTable = {
-      type = "dropdown",
-      name = text,
-      tooltip = tooltip,
-      choices = validChoices,
-      getFunc = getFunc,
-      setFunc = setFunc,
-      warning = warningText,
-      reference = controlName,
-   }
-
-   local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
-   table.insert(tab, controlTable)
-
-   return tab[#tab]
-end
--- LAM1:AddCheckbox(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
-function FAKE_LAM1:AddCheckbox(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
-   if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
-      return LAM1:AddCheckbox(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
+   -- LAM1:AddDropdown(panelID, controlName, text, tooltip, validChoices, getFunc, setFunc, warning, warningText)
+   function FAKE_LAM1:AddDropdown(panelID, controlName, text, tooltip, validChoices, getFunc, setFunc, warning, warningText)
+      if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
+         return LAM1:AddDropdown(panelID, controlName, text, tooltip, validChoices, getFunc, setFunc, warning, warningText)
+      end
+
+      local controlTable = {
+         type = "dropdown",
+         name = text,
+         tooltip = tooltip,
+         choices = validChoices,
+         getFunc = getFunc,
+         setFunc = setFunc,
+         warning = warningText,
+         reference = controlName,
+      }
+
+      local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
+      table.insert(tab, controlTable)
+
+      return tab[#tab]
    end
-
-   local controlTable = {
-      type = "checkbox",
-      name = text,
-      tooltip = tooltip,
-      getFunc = getFunc,
-      setFunc = setFunc,
-      warning = warningText,
-      reference = controlName,
-   }
-
-   local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
-   table.insert(tab, controlTable)
-
-   return tab[#tab]
-end
--- LAM1:AddColorPicker(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
-function FAKE_LAM1:AddColorPicker(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
-   if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
-      return LAM1:AddColorPicker(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
+   -- LAM1:AddCheckbox(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
+   function FAKE_LAM1:AddCheckbox(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
+      if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
+         return LAM1:AddCheckbox(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
+      end
+
+      local controlTable = {
+         type = "checkbox",
+         name = text,
+         tooltip = tooltip,
+         getFunc = getFunc,
+         setFunc = setFunc,
+         warning = warningText,
+         reference = controlName,
+      }
+
+      local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
+      table.insert(tab, controlTable)
+
+      return tab[#tab]
    end
-
-   local controlTable = {
-      type = "colorpicker",
-      name = text,
-      tooltip = tooltip,
-      getFunc = getFunc,
-      setFunc = setFunc,
-      warning = warningText,
-      reference = controlName,
-   }
-
-   local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
-   table.insert(tab, controlTable)
-
-   return tab[#tab]
-end
--- LAM1:AddEditBox(panelID, controlName, text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText)
-function FAKE_LAM1:AddEditBox(panelID, controlName, text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText)
-   if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
-      return LAM1:AddEditBox(panelID, controlName, text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText)
+   -- LAM1:AddColorPicker(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
+   function FAKE_LAM1:AddColorPicker(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
+      if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
+         return LAM1:AddColorPicker(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText)
+      end
+
+      local controlTable = {
+         type = "colorpicker",
+         name = text,
+         tooltip = tooltip,
+         getFunc = getFunc,
+         setFunc = setFunc,
+         warning = warningText,
+         reference = controlName,
+      }
+
+      local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
+      table.insert(tab, controlTable)
+
+      return tab[#tab]
    end
-
-   local controlTable = {
-      type = "editbox",
-      name = text,
-      tooltip = tooltip,
-      getFunc = getFunc,
-      setFunc = setFunc,
-      isMultiline = isMultiLine,
-      warning = warningText,
-      reference = controlName,
-   }
-
-   local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
-   table.insert(tab, controlTable)
-
-   return tab[#tab]
-end
--- LAM1:AddButton(panelID, controlName, text, tooltip, onClick, warning, warningText)
-function FAKE_LAM1:AddButton(panelID, controlName, text, tooltip, onClick, warning, warningText)
-   if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
-      return LAM1:AddButton(panelID, controlName, text, tooltip, onClick, warning, warningText)
+   -- LAM1:AddEditBox(panelID, controlName, text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText)
+   function FAKE_LAM1:AddEditBox(panelID, controlName, text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText)
+      if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
+         return LAM1:AddEditBox(panelID, controlName, text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText)
+      end
+
+      local controlTable = {
+         type = "editbox",
+         name = text,
+         tooltip = tooltip,
+         getFunc = getFunc,
+         setFunc = setFunc,
+         isMultiline = isMultiLine,
+         warning = warningText,
+         reference = controlName,
+      }
+
+      local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
+      table.insert(tab, controlTable)
+
+      return tab[#tab]
    end
+   -- LAM1:AddButton(panelID, controlName, text, tooltip, onClick, warning, warningText)
+   function FAKE_LAM1:AddButton(panelID, controlName, text, tooltip, onClick, warning, warningText)
+      if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
+         return LAM1:AddButton(panelID, controlName, text, tooltip, onClick, warning, warningText)
+      end
+
+      local controlTable = {
+         type = "button",
+         name = text,
+         tooltip = tooltip,
+         func = onClick,
+         warning = warningText,
+         reference = controlName,
+      }
+
+      local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
+      table.insert(tab, controlTable)
+
+      return tab[#tab]
+   end
+   -- LAM1:AddDescription(panelID, controlName, text, titleText)
+   function FAKE_LAM1:AddDescription(panelID, controlName, text, titleText)
+      if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
+         return LAM1:AddDescription(panelID, controlName, text, titleText)
+      end
+
+      local controlTable = {
+         type = "description",
+         title = titleText,
+         text = text,
+         reference = controlName,
+      }
+
+      local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
+      table.insert(tab, controlTable)
+
+      return tab[#tab]
+   end
+   -- LAM1:AddSubMenu(panelID, controlName, text, tooltip)
+   function FAKE_LAM1:AddSubMenu(panelID, controlName, text, tooltip)
+      if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
+         return LAM1:AddSubMenu(panelID, controlName, text, tooltip)
+      end
+
+      local controlTable = {
+         type = "submenu",
+         name = text,
+         tooltip = tooltip,
+         reference = controlName,
+         controls = {},
+      }
+
+      local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
+      table.insert(tab, controlTable)

-   local controlTable = {
-      type = "button",
-      name = text,
-      tooltip = tooltip,
-      func = onClick,
-      warning = warningText,
-      reference = controlName,
-   }
-
-   local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
-   table.insert(tab, controlTable)
-
-   return tab[#tab]
+   return tab[#tab].controls
 end
--- LAM1:AddDescription(panelID, controlName, text, titleText)
-function FAKE_LAM1:AddDescription(panelID, controlName, text, titleText)
-   if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
-      return LAM1:AddDescription(panelID, controlName, text, titleText)
-   end

-   local controlTable = {
-      type = "description",
-      title = titleText,
-      text = text,
-      reference = controlName,
+
+-------------------------------------------------------------------------------
+-- Local functions ------------------------------------------------------------
+-------------------------------------------------------------------------------
+local function CreateSettingsMenu()
+   local panel = {
+      name = "L'AddonMinder",
+      displayName = "|cFFFFB0L'AddonMinder|r",
+      author = "Garkin",
+      version = "0.2",
+      registerForRefresh = true,
+      registerForDefaults = true
    }
+   LAM2:RegisterAddonPanel("LAddMin_Panel", panel)

-   local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
-   table.insert(tab, controlTable)
+   local addonNames = {}
+   for name in pairs(sv.enabled) do
+      table.insert(addonNames, name)
+   end
+   table.sort(addonNames)
+
+   local controlTable = {}
+   for _,name in ipairs(addonNames) do
+      local checkbox = {
+         type = "checkbox",
+         name = name,
+         getFunc = function() return sv.enabled[name] end,
+         setFunc = function(value) sv.enabled[name] = value end,
+         default = false
+      }
+      table.insert(controlTable, checkbox)
+   end

-   return tab[#tab]
-end
--- LAM1:AddSubMenu(panelID, controlName, text, tooltip)
-function FAKE_LAM1:AddSubMenu(panelID, controlName, text, tooltip)
-   if type(panelID) == "userdata" or (type(panelID) == "number" and panelID < 1000) then
-      return LAM1:AddSubMenu(panelID, controlName, text, tooltip)
+   local text = {}
+   for name in pairs(invalidAddons) do
+      table.insert(text, name)
+   end
+   if #text > 0 then
+      table.insert(controlTable, { type = "description", title = "Invalid addons:", text = table.concat(text, "\n- ") })
    end
+
+   table.insert(controlTable, { type = "button", name = GetString(SI_ADDON_MANAGER_RELOAD), func = function() ReloadUI("ingame") end } )
+
+   LAM2:RegisterOptionControls("LAddMin_Panel", controlTable)
+end

-   local controlTable = {
-      type = "submenu",
-      name = text,
-      tooltip = tooltip,
-      reference = controlName,
-      controls = {},
-   }
+local function OnAddonLoaded(code, addon)
+   if addon ~= "LAddMin" then return end

-   local tab = type(panelID) == "table" and panelID or settingsTable[panelID - 1000].controls
-   table.insert(tab, controlTable)
+   sv = ZO_SavedVars:NewAccountWide("LAddMin_ConversionList", 1, "Addons", { enabled = {} })

-   return tab[#tab].controls
+   CreateSettingsMenu()
+
+   CALLBACK_MANAGER:RegisterCallback("LAM-PanelControlsCreated", DelayedCalls)
+
+   EVENT_MANAGER:UnregisterForEvent(addon, code)
 end
+
+EVENT_MANAGER:RegisterForEvent("LAddMin", EVENT_ADD_ON_LOADED, OnAddonLoaded)
diff --git a/LAddMin.txt b/LAddMin.txt
index c28686f..1c57f59 100644
--- a/LAddMin.txt
+++ b/LAddMin.txt
@@ -1,5 +1,5 @@
-## Title: |cFFFFB0LAddMin|r 0.1 - By |c00C000Garkin|r
-## Version: 0.1
+## Title: |cFFFFB0L'AddonMinder|r 0.2 - By |c00C000Garkin|r
+## Version: 0.2
 ## Author: Garkin
 ## APIVersion: 100004
 ## SavedVariables: LAddMin_ConversionList
diff --git a/LibAddonMenu-1.0.txt b/LibAddonMenu-1.0.txt
index 2347272..98cad4c 100644
--- a/LibAddonMenu-1.0.txt
+++ b/LibAddonMenu-1.0.txt
@@ -1,4 +1,5 @@
-## Title: |cFFFFB0LAddMin loader|r 0.1
+## Title: |cFFFFB0L'AddonMinder loader|r
+## Version: 0.1
 ## APIVersion: 100004
 ## DependsOn: LAddMin