Quantcast

Proper update for equip set table

Darthpred [03-02-14 - 15:40]
Proper update for equip set table
Filename
ElvUI_SLE/modules/equipmanager/equipmanager.lua
ElvUI_SLE/modules/equipmanager/options.lua
diff --git a/ElvUI_SLE/modules/equipmanager/equipmanager.lua b/ElvUI_SLE/modules/equipmanager/equipmanager.lua
index e9a5617..df5430d 100755
--- a/ElvUI_SLE/modules/equipmanager/equipmanager.lua
+++ b/ElvUI_SLE/modules/equipmanager/equipmanager.lua
@@ -11,19 +11,6 @@ local GetNumWorldPVPAreas = GetNumWorldPVPAreas
 local GetWorldPVPAreaInfo = GetWorldPVPAreaInfo
 local gsub, strfind = string.gsub, string.find, string.sub

-EM.equipSets = {
-["NONE"] = NONE,
-}
-
-function EM:FillTable()
-	for i = 1, GetNumEquipmentSets() do
-		local name, icon, lessIndex = GetEquipmentSetInfo(i)
-		if name then
-			EM.equipSets[name] = name
-		end
-	end
-end
-
 function EM:Equip(event)
 	local primary = GetSpecialization()
 	if primary ~= nil then
@@ -86,12 +73,10 @@ end
 function EM:Initialize()
 	EM:SpamThrottle()
 	if not E.private.sle.equip.enable then return end
-	EM:FillTable()
 	self:RegisterEvent("PLAYER_ENTERING_WORLD", "Equip")
 	self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "Equip")
 	self:RegisterEvent("PLAYER_TALENT_UPDATE", "Equip")
 	self:RegisterEvent("ZONE_CHANGED", "Equip")
-	self:RegisterEvent("EQUIPMENT_SETS_CHANGED", "FillTable")
 end

 E:RegisterModule(EM:GetName())
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/equipmanager/options.lua b/ElvUI_SLE/modules/equipmanager/options.lua
index 75e92dc..dcaed72 100755
--- a/ElvUI_SLE/modules/equipmanager/options.lua
+++ b/ElvUI_SLE/modules/equipmanager/options.lua
@@ -2,6 +2,20 @@
 local EM = E:GetModule('EquipManager')
 local BI = E:GetModule('BagInfo')

+local sets = {}
+
+local function FillTable()
+	sets = {}
+	sets["NONE"] = NONE
+	for i = 1, GetNumEquipmentSets() do
+		local name, icon, lessIndex = GetEquipmentSetInfo(i)
+		if name then
+			sets[name] = name
+		end
+	end
+	return sets
+end
+
 local function configTable()

 E.Options.args.sle.args.equipmanager = {
@@ -61,7 +75,10 @@ E.Options.args.sle.args.equipmanager = {
 					desc = L["Equip this set when switching to primary talents."],
 					get = function(info) return E.private.sle.equip.primary end,
 					set = function(info, value) E.private.sle.equip.primary = value; end,
-					values = EM.equipSets
+					values = function()
+						FillTable()
+						return sets
+					end,
 				},
 				secondary = {
 					order = 3,
@@ -70,7 +87,10 @@ E.Options.args.sle.args.equipmanager = {
 					desc = L["Equip this set when switching to secondary talents."],
 					get = function(info) return E.private.sle.equip.secondary end,
 					set = function(info, value) E.private.sle.equip.secondary = value end,
-					values = EM.equipSets
+					values = function()
+						FillTable()
+						return sets
+					end,
 				},
 				spacer = {
 					type = "description",
@@ -84,7 +104,10 @@ E.Options.args.sle.args.equipmanager = {
 					desc = L["Equip this set after entering dungeons or raids."],
 					get = function(info) return E.private.sle.equip.instance end,
 					set = function(info, value) E.private.sle.equip.instance = value end,
-					values = EM.equipSets
+					values = function()
+						FillTable()
+						return sets
+					end,
 				},
 				pvp = {
 					order = 6,
@@ -93,7 +116,10 @@ E.Options.args.sle.args.equipmanager = {
 					desc = L["Equip this set after entering battlegrounds or arens."],
 					get = function(info) return E.private.sle.equip.pvp end,
 					set = function(info, value) E.private.sle.equip.pvp = value end,
-					values = EM.equipSets
+					values = function()
+						FillTable()
+						return sets
+					end,
 				},
 			},
 		},