Add interface between old API and new OOP API
Scott Yeskie [05-23-14 - 19:17]
Add interface between old API and new OOP API
diff --git a/lib/LibAddonMenu-1.0.lua b/lib/LibAddonMenu-1.0.lua
index b0ed785..73d74f9 100644
--- a/lib/LibAddonMenu-1.0.lua
+++ b/lib/LibAddonMenu-1.0.lua
@@ -24,6 +24,17 @@ setmetatable(lamPanel, {
end,
})
+function lamPanel:getUniqueName()
+ if lam.forceControlName == nil then
+ self.uniqCounter = self.uniqCounter + 1
+ return self.panelName .. "-" .. self.uniqCounter
+ else
+ local name = lam.forceControlName
+ lam.forceControlName = nil
+ return name
+ end
+end
+
function lamPanel.new(controlPanelID, controlPanelName)
local self = setmetatable({}, lamPanel)
self.panelName = controlPanelName
@@ -487,4 +498,56 @@ function lamPanel:AddSubMenu(text, tooltip)
panel.panelID = panelID
self.panels[panelID] = panel
return panel, scroll
+end
+
+--Adapter code for old interface
+function lam:CreateControlPanel(controlPanelID, controlPanelName)
+ local panel = lamPanel(controlPanelID, controlPanelName)
+ return panel.panelID
+end
+
+function lam:AddHeader(panelID, controlName, ...)
+ self.forceControlName = controlName
+ return self.panels[panelID]:AddHeader(...)
+end
+
+function lam:AddSlider(panelID, controlName, ...)
+ self.forceControlName = controlName
+ return self.panels[panelID]:AddSlider(...)
+end
+
+function lam:AddDropdown(panelID, controlName, ...)
+ self.forceControlName = controlName
+ return self.panels[panelID]:AddDropdown(...)
+end
+
+function lam:AddCheckbox(panelID, controlName, ...)
+ self.forceControlName = controlName
+ return self.panels[panelID]:AddCheckbox(...)
+end
+
+function lam:AddColorPicker(panelID, controlName, ...)
+ self.forceControlName = controlName
+ return self.panels[panelID]:AddColorPicker(...)
+end
+
+function lam:AddEditBox(panelID, controlName, ...)
+ self.forceControlName = controlName
+ return self.panels[panelID]:AddEditBox(...)
+end
+
+function lam:AddButton(panelID, controlName, ...)
+ self.forceControlName = controlName
+ return self.panels[panelID]:AddButton(...)
+end
+
+function lam:AddDescription(panelID, controlName, ...)
+ self.forceControlName = controlName
+ return self.panels[panelID]:AddDescription(...)
+end
+
+function lam:AddSubMenu(panelID, controlName, ...)
+ self.forceControlName = controlName
+ local _, retval = self.panels[panelID]:AddSubMenu(...)
+ return retval
end
\ No newline at end of file