Menu and blacklist changes

Sasky [06-20-14 - 06:02]
Menu and blacklist changes
- Split blacklist, make white+black
- Add menu generation and saved vars

Known issue: Not saving vars properly
Filename
LAddMin.lua
LAddMin.txt
LAddMinCompatability.lua
LAddMinConfig.lua
diff --git a/LAddMin.lua b/LAddMin.lua
index 322f55e..8d9bfbd 100644
--- a/LAddMin.lua
+++ b/LAddMin.lua
@@ -43,22 +43,9 @@ LibStub.minors["LibAddonMenu-1.0"] = 999
 local settingsTable = {}
 local panelIDs = {}

-local excludeList = {
-   "_mainPanel",
-   "_optionsRestacker",
-   "_vicstersAddons",
-   "X4D_LibAntiSpam_CPL",
-   "X4D_Chat_CPL",
-   "SCA",
-   "|cFF2222Wykkyd's|r ConfigPanel",
-   "FTC_SettingsPanel",
-   "SousChefMenu",
-   "SpamFilter_OptionsPanel",
-   "Undiscovered_OptionsPanel",
-   "Azurah_SettingsMenu",
-   "Srendarr_SettingsMenu",
-   "pCHAT_OPTIONS",
- }
+local knownAddons = LAddMinCompatability
+
+LAddMinUpconvertSettings = ZO_SavedVars:NewAccountWide('LAddMin_ConversionList', 2, "list", { cfg = {}})

 -------------------------------------------------------------------------------
 -- FAKE_LAM1 functions --------------------------------------------------------
@@ -68,10 +55,20 @@ do
    function FAKE_LAM1:CreateControlPanel(controlPanelID, controlPanelName)
       local name = controlPanelName:gsub("|[cC]%w%w%w%w%w%w",""):gsub("|[rR]","")

-      for i,v in ipairs(excludeList) do
-         if controlPanelID == v then
+      --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
+            return LAM1:CreateControlPanel(controlPanelID, name)
+          end
+          --Known good. Default to convert
+          LAddMinUpconvertSettings.cfg[name] = true
+      else
+          --Use saved value
+          if not LAddMinUpconvertSettings.cfg[name] then
             return LAM1:CreateControlPanel(controlPanelID, name)
-         end
+          end
       end

       if panelIDs[name] ~= nil then
diff --git a/LAddMin.txt b/LAddMin.txt
index 5aa7723..c28686f 100644
--- a/LAddMin.txt
+++ b/LAddMin.txt
@@ -2,6 +2,7 @@
 ## Version: 0.1
 ## Author: Garkin
 ## APIVersion: 100004
+## SavedVariables: LAddMin_ConversionList

 Libs\LibStub\LibStub.lua
 Libs\LibAddonMenu-1.0\LibAddonMenu-1.0.lua
@@ -19,4 +20,6 @@ Libs\LibAddonMenu-2.0\controls\header.lua
 Libs\LibAddonMenu-2.0\controls\slider.lua
 Libs\LibAddonMenu-2.0\controls\texture.lua

+LAddMinCompatability.lua
 LAddMin.lua
+LAddMinConfig.lua
diff --git a/LAddMinCompatability.lua b/LAddMinCompatability.lua
new file mode 100644
index 0000000..21c94ea
--- /dev/null
+++ b/LAddMinCompatability.lua
@@ -0,0 +1,27 @@
+-- List of addons known to work or not work
+-- Key is the panel name, stripped of colors
+-- Value is true IFF the addon works
+
+LAddMinCompatability = {
+    ["HarvestMap"] = true,
+    ["Wykkyd Settings"] = true,
+
+    ["Sous Chef"] = false,
+    ["ggFrames"] = false,
+    ["FTC Settings"] = false,
+    ["Wykkyd's Config"] = false,
+    ["SpamFilter"] = false,
+    ["Show Motifs"] = false,
+    ["pChat"] = false,
+
+    --TODO: These don't work, but don't have panel name yet.
+--    "_mainPanel",
+--    "_optionsRestacker",
+--    "_vicstersAddons",
+--    "X4D_LibAntiSpam_CPL",
+--    "X4D_Chat_CPL",
+--    "SCA",
+--    "Undiscovered_OptionsPanel",
+--    "Azurah_SettingsMenu",
+--    "Srendarr_SettingsMenu",
+}
diff --git a/LAddMinConfig.lua b/LAddMinConfig.lua
new file mode 100644
index 0000000..c79b9a1
--- /dev/null
+++ b/LAddMinConfig.lua
@@ -0,0 +1,91 @@
+local function createPanel()
+    local LAM = LibStub("LibAddonMenu-2.0")
+    local menuData = {}
+    LAM:RegisterAddonPanel("LAddMin_UI", {
+        type = "panel",
+        name = "LAddMin",
+        displayName = "|cFFFFB0LAddMin",
+        author = "|c00C000Garkin|r and Sasky",
+        version = "0.1",
+    })
+    LAM:RegisterOptionControls("LAddMin_UI", menuData)
+
+    table.insert(menuData,{
+        type = "description",
+        title = "|cFF0000WARNING|r: Using this on addons can break them.",
+        text = "If you have an error after enabling an addon, please disable it.\n" ..
+                "If an addon you check here has an issue, disable the conversion here before filing a bug report."
+    })
+
+    table.insert(menuData,{
+        type = "header",
+        name = "LAM 1.0 Panels"
+    })
+
+    table.insert(menuData,{
+        type = "description",
+        text = "ON to enable LAM2 conversion"
+    })
+
+    --Sort into known working (good), known broken (bad), and unknown (ugly)
+    --(Couldn't resist... ~Sasky)
+    local good, ugly, bad = {}, {}, {}
+    for k,_ in pairs(LAddMinUpconvertSettings.cfg) do
+        local checkbox = {
+            type = "checkbox",
+            name = k,
+            getFunc = function() return LAddMinUpconvertSettings.cfg[k] end,
+            setFunc = function(val) LAddMinUpconvertSettings.cfg[k] = val end
+        }
+
+        if LAddMinCompatability[k] == nil then
+            table.insert(ugly, checkbox)
+        else
+            if LAddMinCompatability[k] then
+                table.insert(good, checkbox)
+            else
+                checkbox.warning = "Enabling this could cause " .. k .. " to stop working."
+                table.insert(bad, checkbox)
+            end
+        end
+    end
+
+    local function checkboxSort(l,r)
+        return l.name < r.name
+    end
+
+    table.sort(good, checkboxSort)
+    table.sort(bad, checkboxSort)
+    table.sort(ugly, checkboxSort)
+
+    if #good > 0 then
+        table.insert(menuData,{
+            type = "submenu",
+            name = "|c00FF00Working addons",
+            tooltip = "These menus convert with no issues.",
+            controls = good
+        })
+    end
+
+    if #ugly > 0 then
+        table.insert(menuData,{
+            type = "submenu",
+            name = "|cFFFF00Unknown addons",
+            tooltip = "We haven't tested if these menus work.",
+            controls = ugly
+        })
+    end
+
+    if #bad > 0 then
+        table.insert(menuData,{
+            type = "submenu",
+            name = "|cFF0000Not convertible addons",
+            tooltip = "These menus have known issues up to the addon not working.",
+            controls = bad
+        })
+    end
+
+    EVENT_MANAGER:UnregisterForEvent("LAddMinUI", EVENT_PLAYER_ACTIVATED)
+end
+
+EVENT_MANAGER:RegisterForEvent("LAddMinUI", EVENT_PLAYER_ACTIVATED, createPanel)
\ No newline at end of file