Quantcast

Loot Needs Testing Darth

Repooc [08-07-14 - 01:35]
Loot Needs Testing Darth
Filename
ElvUI_SLE/defaults/profile.lua
ElvUI_SLE/modules/loot.lua
ElvUI_SLE/options/loot_c.lua
diff --git a/ElvUI_SLE/defaults/profile.lua b/ElvUI_SLE/defaults/profile.lua
index ba9de58..df5238b 100644
--- a/ElvUI_SLE/defaults/profile.lua
+++ b/ElvUI_SLE/defaults/profile.lua
@@ -1,10 +1,6 @@
 local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB

 P['sle'] = {
-	--Autoloot
-	['lootwin'] = false,
-	['lootalpha'] = 1,
-
 	--Auto release
 	['pvpautorelease'] = true,

@@ -243,6 +239,24 @@ P['sle'] = {
 		['leishen'] = false,
 	},

+	--Loot (Restructured)
+	['loot'] = {
+		['enable'] = false,
+		['autoconfirm'] = false,
+		['autogreed'] = false,
+		['autode'] = false,
+		['announcer'] = {
+			['enable'] = false,
+			['auto'] = true,
+			['channel'] = "RAID",
+			['quality'] = "EPIC",
+		},
+		['history'] = {
+			['alpha'] = false,
+			['autohide'] = false,
+		},
+	},
+
 	--Minimap Module
 	['minimap'] = {
 		['enable'] = false,
@@ -304,12 +318,6 @@ P['sle'] = {
 		['spacing'] = 3,
 	},

-	--Loot
-	['loot'] = {
-		['quality'] = "EPIC",
-		['chat'] = "RAID",
-		['auto'] = true,
-	},

 	--Tooltip Faction Icon
 	["tooltipicon"] = false,
diff --git a/ElvUI_SLE/modules/loot.lua b/ElvUI_SLE/modules/loot.lua
index 3476624..813498f 100644
--- a/ElvUI_SLE/modules/loot.lua
+++ b/ElvUI_SLE/modules/loot.lua
@@ -1,6 +1,8 @@
 local E, L, V, P, G, _ = unpack(ElvUI);
 local LT = E:GetModule('SLE_Loot')
-local check, ann, GrDes = false, false, false
+local db = {}
+
+local check, GrDes = false, false
 local t = 0
 local n = 0
 local loot, loottemp, numbers = {}, {}, {}
@@ -65,13 +67,13 @@ end

 local function Channel()
 	local channel
-	if E.db.sle.loot.chat ~= "SAY" and IsPartyLFG() then
+	if db.announcer.channel ~= "SAY" and IsPartyLFG() then
 		return "INSTANCE_CHAT"
 	end
-	if E.db.sle.loot.chat == "RAID" and not IsInRaid() then
+	if db.announcer.channel == "RAID" and not IsInRaid() then
 		return "PARTY"
 	end
-	return E.db.sle.loot.chat
+	return db.announcer.channel
 end

 local function List()
@@ -93,9 +95,9 @@ local function Announce(event)
 	if event ~= "LOOT_OPENED" then return end
 	if not IsInGroup() then return end -- not in group, exit.
 	local m = 0
-	local q = E.db.sle.loot.quality == "EPIC" and 4 or E.db.sle.loot.quality == "RARE" and 3 or E.db.sle.loot.quality == "UNCOMMON" and 2
+	local q = db.announcer.quality == "EPIC" and 4 or db.announcer.quality == "RARE" and 3 or db.announcer.quality == "UNCOMMON" and 2

-	if (Check() and E.db.sle.loot.auto) or (IsLeftControlKeyDown() and (IsInGroup() or IsInRaid())) then
+	if (Check() and db.announcer.auto) or (IsLeftControlKeyDown() and (IsInGroup() or IsInRaid())) then
 		for i = 1, GetNumLootItems() do
 			if GetLootSlotType(i) == 1 then
 				for j = 1, t do
@@ -122,15 +124,6 @@ local function Announce(event)
 	end
 end

-function LT:LootShow()
-	local instance = IsInInstance()
-	LootHistoryFrame:SetAlpha(E.db.sle.lootalpha or 1)
-
-	if (not instance and E.db.sle.lootwin) then
-		LootHistoryFrame:Hide()
-	end
-end
-
 local function HandleRoll(event, id)
 	if not GrDes then return end

@@ -145,7 +138,7 @@ local function HandleRoll(event, id)
 	if UnitLevel("player") ~= Maxed then return end

 	if(id and select(4, GetLootRollItemInfo(id))== 2 and not (select(5, GetLootRollItemInfo(id)))) then
-		if E.private.sle.loot.autodisenchant and RollOnLoot(id, 3) then
+		if E.db.sle.loot.autode and RollOnLoot(id, 3) then
 			RollOnLoot(id, 3)
 		else
 			RollOnLoot(id, 2)
@@ -158,17 +151,36 @@ local function HandleEvent(event, ...)
 		local arg1, arg2 = ...
 		ConfirmLootRoll(arg1, arg2)
 	elseif event == "LOOT_OPENED" or event == "LOOT_BIND_CONFIRM" then
-		if ann then Announce(event) end
-		count = GetNumLootItems()
-		if count == 0 then CloseLoot() return end
-		for slot = 1, count do
-			ConfirmLootSlot(slot)
+		if db.announcer.enable then
+			Announce(event)
+		end
+		if db.autoconfirm then
+			local count = GetNumLootItems()
+			if count == 0 then --[[CloseLoot()]] return end
+			for slot = 1, count do
+				ConfirmLootSlot(slot)
+			end
 		end
 	end
 end

+local function LoadConfig(event, addon)
+	if addon ~= "ElvUI_Config" then return end
+	LT:UnregisterEvent("ADDON_LOADED")
+	LT:Update()
+end
+
+function LT:LootShow()
+	local instance = IsInInstance()
+	LootHistoryFrame:SetAlpha(db.history.alpha or 1)
+
+	if (not instance and db.history.autohide) then
+		LootHistoryFrame:Hide()
+	end
+end
+
 function LT:Update()
-	if E.private.sle.loot.autogreed or E.private.sle.loot.autodisenchant then
+	if db.history.autogreed or db.history.autode then
 		GrDes = true
 		E.db.general.autoRoll = false
 	else
@@ -183,14 +195,10 @@ function LT:Update()
 	end
 end

-local function LoadConfig(event, addon)
-	if addon ~= "ElvUI_Config" then return end
-	LT:UnregisterEvent("ADDON_LOADED")
-	LT:Update()
-end
-
 function LT:Initialize()
-	ann = E.private.sle.loot.enable
+	db = E.db.sle.loot
+	--if db.enable then print(db.enable) else print("false") end
+	if not db.enable then return end

 	self:Update()
 	UIParent:UnregisterEvent("LOOT_BIND_CONFIRM")
diff --git a/ElvUI_SLE/options/loot_c.lua b/ElvUI_SLE/options/loot_c.lua
index 28207ce..9584fbf 100644
--- a/ElvUI_SLE/options/loot_c.lua
+++ b/ElvUI_SLE/options/loot_c.lua
@@ -7,42 +7,57 @@ local function configTable()
 		type = "group",
 		name = L['Loot'],
 		args = {
-			autoconfirm = {
+			enable = {
 				order = 1,
 				type = "toggle",
+				name = L["Enable"],
+				get = function(info) return E.db.sle.loot.enable end,
+				set = function(info, value) E.db.sle.loot.enable = value; E:StaticPopup_Show("CONFIG_RL") end
+			},
+			space1 = {
+				order = 2,
+				type = 'description',
+				name = "",
+			},
+			autoconfirm = {
+				order = 3,
+				type = "toggle",
 				name = "Auto Confirm",
 				desc = "Automatically click OK on BOP items",
-				get = function(info) return E.private.sle.loot.autoconfirm end,
-				set = function(info,value) E.private.sle.loot.autoconfirm = value; end,
+				disabled = function() return not E.db.sle.loot.enable end,
+				get = function(info) return E.db.sle.loot.autoconfirm end,
+				set = function(info, value) E.db.sle.loot.autoconfirm = value; end,
 			},
 			autogreed = {
-				order = 2,
+				order = 4,
 				type = "toggle",
 				name = "Auto Greed",
 				desc = "Automatically greed uncommon (green) quality items at max level",
-				get = function(info) return E.private.sle.loot.autogreed end,
-				set = function(info,value) E.private.sle.loot.autogreed = value; LT:Update() end,
+				disabled = function() return not E.db.sle.loot.enable end,
+				get = function(info) return E.db.sle.loot.autogreed end,
+				set = function(info, value) E.db.sle.loot.autogreed = value; LT:Update() end,
 			},
-			autodisenchant = {
-				order = 3,
+			autode = {
+				order = 5,
 				type = "toggle",
 				name = "Auto Disenchant",
 				desc = "Automatically disenchant uncommon (green) quality items at max level",
-				get = function(info) return E.private.sle.loot.autodisenchant end,
-				set = function(info,value) E.private.sle.loot.autodisenchant = value; LT:Update() end,
+				disabled = function() return not E.db.sle.loot.enable end,
+				get = function(info) return E.db.sle.loot.autode end,
+				set = function(info, value) E.db.sle.loot.autode = value; LT:Update() end,
 			},
-			space1 = {
-				order = 4,
+			space2 = {
+				order = 6,
 				type = 'description',
 				name = "",
 			},
-			space2 = {
-				order = 4,
+			space3 = {
+				order = 6,
 				type = 'description',
 				name = "",
 			},
-			lootannouncer = {
-				order = 5,
+			announcer = {
+				order = 7,
 				type = "group",
 				name = L["Loot Announcer"],
 				args = {
@@ -60,17 +75,18 @@ local function configTable()
 						order = 3,
 						type = "toggle",
 						name = L["Enable"],
-						get = function(info) return E.private.sle.loot.enable end,
-						set = function(info, value) E.private.sle.loot.enable = value; E:StaticPopup_Show("CONFIG_RL") end
+						disabled = function() return not E.db.sle.loot.enable end,
+						get = function(info) return E.db.sle.loot.announcer.enable end,
+						set = function(info, value) E.db.sle.loot.announcer.enable = value; E:StaticPopup_Show("CONFIG_RL") end
 					},
 					auto = {
 						order = 4,
 						type = "toggle",
 						name = L["Auto Announce"],
 						desc = L["AUTOANNOUNCE_DESC"],
-						disabled = function() return not E.private.sle.loot.enable end,
-						get = function(info) return E.db.sle.loot.auto end,
-						set = function(info, value) E.db.sle.loot.auto = value; end
+						disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.announcer.enable end,
+						get = function(info) return E.db.sle.loot.announcer.auto end,
+						set = function(info, value) E.db.sle.loot.announcer.auto = value; end
 					},
 					spacer = {
 						order = 5,
@@ -82,23 +98,23 @@ local function configTable()
 						type = "select",
 						name = L["Loot Quality"],
 						desc = L["Sets the minimum loot threshold to announce."],
-						disabled = function() return not E.private.sle.loot.enable end,
-						get = function(info) return E.db.sle.loot.quality end,
-						set = function(info, value) E.db.sle.loot.quality = value;  end,
+						disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.announcer.enable end,
+						get = function(info) return E.db.sle.loot.announcer.quality end,
+						set = function(info, value) E.db.sle.loot.announcer.quality = value;  end,
 						values = {
 							['EPIC'] = "|cffA335EE"..ITEM_QUALITY4_DESC.."|r",
 							['RARE'] = "|cff0070DD"..ITEM_QUALITY3_DESC.."|r",
 							['UNCOMMON'] = "|cff1EFF00"..ITEM_QUALITY2_DESC.."|r",
 						},
 					},
-					chat = {
+					channel = {
 						order = 10,
 						type = "select",
 						name = L["Chat"],
 						desc = L["Select chat channel to announce loot to."],
-						disabled = function() return not E.private.sle.loot.enable end,
-						get = function(info) return E.db.sle.loot.chat end,
-						set = function(info, value) E.db.sle.loot.chat = value;  end,
+						disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.announcer.enable end,
+						get = function(info) return E.db.sle.loot.announcer.channel end,
+						set = function(info, value) E.db.sle.loot.announcer.channel = value;  end,
 						values = {
 							['RAID'] = "|cffFF7F00"..RAID.."|r",
 							['PARTY'] = "|cffAAAAFF"..PARTY.."|r",
@@ -107,8 +123,8 @@ local function configTable()
 					},
 				},
 			},
-			lootwindow = {
-				order = 6,
+			history = {
+				order = 8,
 				type = "group",
 				name = L["Loot Roll History"],
 				args = {
@@ -127,8 +143,9 @@ local function configTable()
 						type = "toggle",
 						name = L["Auto hide"],
 						desc = L["Automaticaly hides Loot Roll Histroy frame when leaving the instance."],
-						get = function(info) return E.db.sle.lootwin end,
-						set = function(info, value) E.db.sle.lootwin = value; LT:LootShow() end
+						disabled = function() return not E.db.sle.loot.enable end,
+						get = function(info) return E.db.sle.loot.history.autohide end,
+						set = function(info, value) E.db.sle.loot.history.autohide = value; LT:LootShow() end
 					},
 					alpha = {
 						order = 4,
@@ -136,8 +153,9 @@ local function configTable()
 						name = L['Alpha'],
 						desc = L["Sets the alpha of Loot Roll Histroy frame."],
 						min = 0.2, max = 1, step = 0.1,
-						get = function(info) return E.db.sle.lootalpha end,
-						set = function(info, value) E.db.sle.lootalpha = value; LT:LootShow() end,
+						disabled = function() return not E.db.sle.loot.enable end,
+						get = function(info) return E.db.sle.loot.history.alpha end,
+						set = function(info, value) E.db.sle.loot.history.alpha = value; LT:LootShow() end,
 					},
 				},
 			},