Quantcast

options!

Darthpred [10-16-16 - 11:14]
options!
Filename
ElvUI_SLE/defaults/profile.lua
ElvUI_SLE/modules/baginfo.lua
ElvUI_SLE/modules/bags/artifactpower.lua
ElvUI_SLE/modules/bags/baginfo.lua
ElvUI_SLE/modules/bags/load_bags.xml
ElvUI_SLE/modules/load_modules.xml
ElvUI_SLE/options/bags_c.lua
diff --git a/ElvUI_SLE/defaults/profile.lua b/ElvUI_SLE/defaults/profile.lua
index c97a647..720894f 100644
--- a/ElvUI_SLE/defaults/profile.lua
+++ b/ElvUI_SLE/defaults/profile.lua
@@ -76,6 +76,16 @@ P["sle"] = {
 		--Bags
 	["bags"] = {
 		["lootflash"] = true,
+		["artifactPower"] = {
+			["enable"] = false,
+			["color"] = {r = 1, g = 0, b = 0},
+			["short"] = false,
+			["fonts"] = {
+				["font"] = "PT Sans Narrow",
+				["size"] = 12,
+				["outline"] = "OUTLINE",
+			},
+		},
 	},
 	--Blizzard
 	["blizzard"] = {
diff --git a/ElvUI_SLE/modules/baginfo.lua b/ElvUI_SLE/modules/baginfo.lua
deleted file mode 100644
index c422f22..0000000
--- a/ElvUI_SLE/modules/baginfo.lua
+++ /dev/null
@@ -1,141 +0,0 @@
-local SLE, T, E, L, V, P, G = unpack(select(2, ...))
-local BI = SLE:NewModule('BagInfo', 'AceHook-3.0', 'AceEvent-3.0', 'AceTimer-3.0')
-local B = E:GetModule('Bags')
-local _G = _G
-local byte = string.byte
-
-local updateTimer
-BI.containers = {}
-BI.infoArray = {}
-BI.equipmentMap = {}
-local EquipmentManager_UnpackLocation = EquipmentManager_UnpackLocation
-
-local function Utf8Sub(str, start, numChars)
-	local currentIndex = start
-	while numChars > 0 and currentIndex <= #str do
-		local char = byte(str, currentIndex)
-
-		if char > 240 then
-			currentIndex = currentIndex + 4
-		elseif char > 225 then
-			currentIndex = currentIndex + 3
-		elseif char > 192 then
-			currentIndex = currentIndex + 2
-		else
-			currentIndex = currentIndex + 1
-		end
-
-		numChars = numChars -1
-	end
-
-	return str:sub(start, currentIndex - 1)
-end
-
-local function MapKey(bag, slot)
-	return T.format("%d_%d", bag, slot)
-end
-
-local quickFormat = {
-	[0] = function(font, map) font:SetText() end,
-	[1] = function(font, map) font:SetFormattedText("|cffffffaa%s|r", Utf8Sub(map[1], 1, 4)) end,
-	[2] = function(font, map) font:SetFormattedText("|cffffffaa%s %s|r", Utf8Sub(map[1], 1, 4), Utf8Sub(map[2], 1, 4)) end,
-	[3] = function(font, map) font:SetFormattedText("|cffffffaa%s %s %s|r", Utf8Sub(map[1], 1, 4), Utf8Sub(map[2], 1, 4), Utf8Sub(map[3], 1, 4)) end,
-}
-
-local function BuildEquipmentMap(clear)
-	-- clear mapped names
-	for k, v in T.pairs(BI.equipmentMap) do
-		T.twipe(v)
-	end
-
-	if clear then return end
-
-	local name, player, bank, bags, slot, bag, key
-
-	for i = 1, T.GetNumEquipmentSets() do
-		name = T.GetEquipmentSetInfo(i)
-		T.GetEquipmentSetLocations(name, BI.infoArray)
-		for _, location in T.pairs(BI.infoArray) do
-			if T.type(location) == "number" and (location < -1 or location > 1) then
-				player, bank, bags, _, slot, bag = EquipmentManager_UnpackLocation(location)
-				if ((bank or bags) and slot and bag) then
-					key = MapKey(bag, slot)
-					BI.equipmentMap[key] = BI.equipmentMap[key] or {}
-					T.tinsert(BI.equipmentMap[key], name)
-				end
-			end
-		end
-	end
-end
-
-local function UpdateContainerFrame(frame, bag, slot)
-	if (not frame.equipmentinfo) then
-		frame.equipmentinfo = frame:CreateFontString(nil, "OVERLAY")
-		frame.equipmentinfo:FontTemplate(E.media.font, 12, "THINOUTLINE")
-		frame.equipmentinfo:SetWordWrap(true)
-		frame.equipmentinfo:SetJustifyH('CENTER')
-		frame.equipmentinfo:SetJustifyV('MIDDLE')
-	end
-
-	if (frame.equipmentinfo) then
-		frame.equipmentinfo:SetAllPoints(frame)
-
-		local key = MapKey(bag, slot)
-		if BI.equipmentMap[key] then
-			quickFormat[#BI.equipmentMap[key] < 4 and #BI.equipmentMap[key] or 3](frame.equipmentinfo, BI.equipmentMap[key])
-		else
-			quickFormat[0](frame.equipmentinfo, nil)
-		end
-	end
-end
-
-local function UpdateBagInformation(clear)
-	updateTimer = nil
-
-	BuildEquipmentMap(clear)
-	for _, container in T.pairs(BI.containers) do
-		for _, bagID in T.ipairs(container.BagIDs) do
-			for slotID = 1, T.GetContainerNumSlots(bagID) do
-				UpdateContainerFrame(container.Bags[bagID][slotID], bagID, slotID)
-			end
-		end
-	end
-end
-
-local function DelayUpdateBagInformation(event)
-	-- delay to make sure multiple bag events are consolidated to one update.
-	if not updateTimer then
-		updateTimer = BI:ScheduleTimer(UpdateBagInformation, .25)
-	end
-end
-
-function BI:ToggleSettings()
-	if updateTimer then
-		self:CancelTimer(updateTimer)
-	end
-
-	if E.private.sle.equip.setoverlay then
-		self:RegisterEvent("EQUIPMENT_SETS_CHANGED", DelayUpdateBagInformation)
-		self:RegisterEvent("BAG_UPDATE", DelayUpdateBagInformation)
-		UpdateBagInformation()
-	else
-		self:UnregisterEvent("EQUIPMENT_SETS_CHANGED")
-		self:UnregisterEvent("BAG_UPDATE")
-		UpdateBagInformation(true)
-	end
-end
-
-function BI:Initialize()
-	if not SLE.initialized or not E.private.bags.enable then return end
-
-	T.tinsert(BI.containers, _G["ElvUI_ContainerFrame"])
-	self:SecureHook(B, "OpenBank", function()
-		self:Unhook(B, "OpenBank")
-		T.tinsert(BI.containers, _G["ElvUI_BankContainerFrame"])
-		BI:ToggleSettings()
-	end)
-
-	BI:ToggleSettings()
-end
-
-SLE:RegisterModule(BI:GetName())
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/bags/artifactpower.lua b/ElvUI_SLE/modules/bags/artifactpower.lua
index 52fe1e7..f791803 100644
--- a/ElvUI_SLE/modules/bags/artifactpower.lua
+++ b/ElvUI_SLE/modules/bags/artifactpower.lua
@@ -3,7 +3,7 @@ local AP = SLE:NewModule("ArtifactPowerBags", 'AceHook-3.0', 'AceEvent-3.0')
 local B = E:GetModule('Bags')
 local _G = _G
 local tooltipScanner
-local tooltipName = "ArtifactPowerTooltipScanner"
+local tooltipName = "SLE_ArtifactPowerTooltipScanner"
 local EMPOWERING_SPELL_ID = 227907
 local empoweringSpellName
 local arcanePower
@@ -23,9 +23,9 @@ local function GetItemLinkArtifactPower(slotLink)
 			end

 			local ap = tooltipText:gsub("[,%.]", ""):match("%d.-%s") or ""
-
-			tooltipScanner:Hide()
-			return tonumber(ap);
+			tooltipScanner:Hide()
+			if E.db.sle.bags.artifactPower.short then ap = E:ShortValue(ap) end
+			return ap
 		else
 			return nil
 		end
@@ -35,26 +35,31 @@ local function GetItemLinkArtifactPower(slotLink)
 end

 local function UpdateContainerFrame(frame, bagID, slotID)
-	if (not frame.artifactpowerinfo) then
+	if (not frame.artifactpowerinfo) and E.db.sle.bags.artifactPower.enable then
 		frame.artifactpowerinfo = frame:CreateFontString(nil, 'OVERLAY')
 		frame.artifactpowerinfo:Point("BOTTOMRIGHT", 0, 2)
-		frame.artifactpowerinfo:FontTemplate(E.LSM:Fetch("font", E.db.bags.itemLevelFont), E.db.bags.itemLevelFontSize, E.db.bags.itemLevelFontOutline)
-		frame.artifactpowerinfo:SetText("")
 		frame.artifactpowerinfo:SetAllPoints(frame)
-		frame.artifactpowerinfo:SetTextColor(255, 0, 0)
 	end
-	--local frame = _G["ElvUI_ContainerFrameBag"..bagID.."Slot"..slotID]

-	if (frame.artifactpowerinfo) then
-		local slotLink = GetContainerItemLink(bagID,slotID)
+	if E.db.sle.bags.artifactPower.enable then
+		frame.artifactpowerinfo:FontTemplate(E.LSM:Fetch("font", E.db.sle.bags.artifactPower.fonts.font), E.db.sle.bags.artifactPower.fonts.size, E.db.sle.bags.artifactPower.fonts.outline)
+		frame.artifactpowerinfo:SetText("")
+		local r,g,b = E.db.sle.bags.artifactPower.color.r, E.db.sle.bags.artifactPower.color.g, E.db.sle.bags.artifactPower.color.b
+		frame.artifactpowerinfo:SetTextColor(r, g, b)
+
+		if (frame.artifactpowerinfo) then
+			local slotLink = GetContainerItemLink(bagID,slotID)


-		arcanePower = GetItemLinkArtifactPower(slotLink)
-		frame.artifactpowerinfo:SetText(arcanePower)
+			arcanePower = GetItemLinkArtifactPower(slotLink)
+			frame.artifactpowerinfo:SetText(arcanePower)
+		end
+	elseif not E.db.sle.bags.artifactPower.enable and frame.artifactpowerinfo then
+		frame.artifactpowerinfo:SetText("")
 	end
 end

-local bagUpdate = function(self)
+function AP:bagUpdate()
 	for _, container in T.pairs(AP.containers) do
 		for _, bagID in T.ipairs(container.BagIDs) do
 			for slotID = 1, T.GetContainerNumSlots(bagID) do
@@ -84,14 +89,14 @@ local bagUpdate = function(self)
 end

 function AP:ToggleSettings()
-	self:RegisterEvent("BAG_UPDATE_DELAYED", bagUpdate)
-	self:RegisterEvent("ARTIFACT_UPDATE", bagUpdate)
-	self:RegisterEvent("BANKFRAME_OPENED", bagUpdate)
-	self:RegisterEvent("PLAYERBANKSLOTS_CHANGED", bagUpdate)
-	self:RegisterEvent("BANKFRAME_CLOSED", bagUpdate)
-	self:RegisterEvent("BAG_UPDATE", bagUpdate)
-	self:RegisterEvent("ITEM_LOCKED", bagUpdate)
-	self:RegisterEvent("ITEM_LOCK_CHANGED", bagUpdate)
+	self:RegisterEvent("BAG_UPDATE_DELAYED", "bagUpdate")
+	self:RegisterEvent("ARTIFACT_UPDATE", "bagUpdate")
+	self:RegisterEvent("BANKFRAME_OPENED", "bagUpdate")
+	self:RegisterEvent("PLAYERBANKSLOTS_CHANGED", "bagUpdate")
+	self:RegisterEvent("BANKFRAME_CLOSED", "bagUpdate")
+	self:RegisterEvent("BAG_UPDATE", "bagUpdate")
+	self:RegisterEvent("ITEM_LOCKED", "bagUpdate")
+	self:RegisterEvent("ITEM_LOCK_CHANGED", "bagUpdate")
 end

 function AP:Initialize()
diff --git a/ElvUI_SLE/modules/bags/baginfo.lua b/ElvUI_SLE/modules/bags/baginfo.lua
new file mode 100644
index 0000000..c422f22
--- /dev/null
+++ b/ElvUI_SLE/modules/bags/baginfo.lua
@@ -0,0 +1,141 @@
+local SLE, T, E, L, V, P, G = unpack(select(2, ...))
+local BI = SLE:NewModule('BagInfo', 'AceHook-3.0', 'AceEvent-3.0', 'AceTimer-3.0')
+local B = E:GetModule('Bags')
+local _G = _G
+local byte = string.byte
+
+local updateTimer
+BI.containers = {}
+BI.infoArray = {}
+BI.equipmentMap = {}
+local EquipmentManager_UnpackLocation = EquipmentManager_UnpackLocation
+
+local function Utf8Sub(str, start, numChars)
+	local currentIndex = start
+	while numChars > 0 and currentIndex <= #str do
+		local char = byte(str, currentIndex)
+
+		if char > 240 then
+			currentIndex = currentIndex + 4
+		elseif char > 225 then
+			currentIndex = currentIndex + 3
+		elseif char > 192 then
+			currentIndex = currentIndex + 2
+		else
+			currentIndex = currentIndex + 1
+		end
+
+		numChars = numChars -1
+	end
+
+	return str:sub(start, currentIndex - 1)
+end
+
+local function MapKey(bag, slot)
+	return T.format("%d_%d", bag, slot)
+end
+
+local quickFormat = {
+	[0] = function(font, map) font:SetText() end,
+	[1] = function(font, map) font:SetFormattedText("|cffffffaa%s|r", Utf8Sub(map[1], 1, 4)) end,
+	[2] = function(font, map) font:SetFormattedText("|cffffffaa%s %s|r", Utf8Sub(map[1], 1, 4), Utf8Sub(map[2], 1, 4)) end,
+	[3] = function(font, map) font:SetFormattedText("|cffffffaa%s %s %s|r", Utf8Sub(map[1], 1, 4), Utf8Sub(map[2], 1, 4), Utf8Sub(map[3], 1, 4)) end,
+}
+
+local function BuildEquipmentMap(clear)
+	-- clear mapped names
+	for k, v in T.pairs(BI.equipmentMap) do
+		T.twipe(v)
+	end
+
+	if clear then return end
+
+	local name, player, bank, bags, slot, bag, key
+
+	for i = 1, T.GetNumEquipmentSets() do
+		name = T.GetEquipmentSetInfo(i)
+		T.GetEquipmentSetLocations(name, BI.infoArray)
+		for _, location in T.pairs(BI.infoArray) do
+			if T.type(location) == "number" and (location < -1 or location > 1) then
+				player, bank, bags, _, slot, bag = EquipmentManager_UnpackLocation(location)
+				if ((bank or bags) and slot and bag) then
+					key = MapKey(bag, slot)
+					BI.equipmentMap[key] = BI.equipmentMap[key] or {}
+					T.tinsert(BI.equipmentMap[key], name)
+				end
+			end
+		end
+	end
+end
+
+local function UpdateContainerFrame(frame, bag, slot)
+	if (not frame.equipmentinfo) then
+		frame.equipmentinfo = frame:CreateFontString(nil, "OVERLAY")
+		frame.equipmentinfo:FontTemplate(E.media.font, 12, "THINOUTLINE")
+		frame.equipmentinfo:SetWordWrap(true)
+		frame.equipmentinfo:SetJustifyH('CENTER')
+		frame.equipmentinfo:SetJustifyV('MIDDLE')
+	end
+
+	if (frame.equipmentinfo) then
+		frame.equipmentinfo:SetAllPoints(frame)
+
+		local key = MapKey(bag, slot)
+		if BI.equipmentMap[key] then
+			quickFormat[#BI.equipmentMap[key] < 4 and #BI.equipmentMap[key] or 3](frame.equipmentinfo, BI.equipmentMap[key])
+		else
+			quickFormat[0](frame.equipmentinfo, nil)
+		end
+	end
+end
+
+local function UpdateBagInformation(clear)
+	updateTimer = nil
+
+	BuildEquipmentMap(clear)
+	for _, container in T.pairs(BI.containers) do
+		for _, bagID in T.ipairs(container.BagIDs) do
+			for slotID = 1, T.GetContainerNumSlots(bagID) do
+				UpdateContainerFrame(container.Bags[bagID][slotID], bagID, slotID)
+			end
+		end
+	end
+end
+
+local function DelayUpdateBagInformation(event)
+	-- delay to make sure multiple bag events are consolidated to one update.
+	if not updateTimer then
+		updateTimer = BI:ScheduleTimer(UpdateBagInformation, .25)
+	end
+end
+
+function BI:ToggleSettings()
+	if updateTimer then
+		self:CancelTimer(updateTimer)
+	end
+
+	if E.private.sle.equip.setoverlay then
+		self:RegisterEvent("EQUIPMENT_SETS_CHANGED", DelayUpdateBagInformation)
+		self:RegisterEvent("BAG_UPDATE", DelayUpdateBagInformation)
+		UpdateBagInformation()
+	else
+		self:UnregisterEvent("EQUIPMENT_SETS_CHANGED")
+		self:UnregisterEvent("BAG_UPDATE")
+		UpdateBagInformation(true)
+	end
+end
+
+function BI:Initialize()
+	if not SLE.initialized or not E.private.bags.enable then return end
+
+	T.tinsert(BI.containers, _G["ElvUI_ContainerFrame"])
+	self:SecureHook(B, "OpenBank", function()
+		self:Unhook(B, "OpenBank")
+		T.tinsert(BI.containers, _G["ElvUI_BankContainerFrame"])
+		BI:ToggleSettings()
+	end)
+
+	BI:ToggleSettings()
+end
+
+SLE:RegisterModule(BI:GetName())
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/bags/load_bags.xml b/ElvUI_SLE/modules/bags/load_bags.xml
index f76cfb2..17ce2b6 100644
--- a/ElvUI_SLE/modules/bags/load_bags.xml
+++ b/ElvUI_SLE/modules/bags/load_bags.xml
@@ -1,4 +1,5 @@
 <Ui xmlns="http://www.blizzard.com/wow/ui/">
 	<Script file="bags.lua"/>
+	<Script file="baginfo.lua"/>
 	<Script file="artifactpower.lua"/>
 </Ui>
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/load_modules.xml b/ElvUI_SLE/modules/load_modules.xml
index 6a24bd6..1b5e91f 100644
--- a/ElvUI_SLE/modules/load_modules.xml
+++ b/ElvUI_SLE/modules/load_modules.xml
@@ -6,7 +6,6 @@
 	<Script file='auras.lua'/>
 	<Script file='backgrounds.lua'/>
 	<Include file='bags\load_bags.xml'/>
-	<Script file='baginfo.lua'/>
 	<Script file='blizzard.lua'/>
 	<Include file='chat\load_chat.xml'/>
 	<Script file='datatexts.lua'/>
diff --git a/ElvUI_SLE/options/bags_c.lua b/ElvUI_SLE/options/bags_c.lua
index 1a9b332..253b3ea 100644
--- a/ElvUI_SLE/options/bags_c.lua
+++ b/ElvUI_SLE/options/bags_c.lua
@@ -1,4 +1,6 @@
 local SLE, T, E, L, V, P, G = unpack(select(2, ...))
+local ARTIFACT_POWER = ARTIFACT_POWER
+local AP = SLE:GetModule("ArtifactPowerBags")

 local function configTable()
 	if not SLE.initialized then return end
@@ -29,6 +31,77 @@ local function configTable()
 				get = function(info) return E.db.sle.bags.lootflash end,
 				set = function(info, value)	E.db.sle.bags.lootflash = value end,
 			},
+			artefact = {
+				order = 20,
+				type = "group",
+				guiInline = true,
+				name = ARTIFACT_POWER,
+				get = function(info) return E.db.sle.bags.artifactPower[ info[#info] ] end,
+				set = function(info, value) E.db.sle.bags.artifactPower[ info[#info] ] = value; AP:bagUpdate() end,
+				args = {
+					enable = {
+						order = 1,
+						type = "toggle",
+						name = L["Enable"],
+					},
+					color = {
+						type = "color",
+						order = 2,
+						name = L["Color"],
+						hasAlpha = false,
+						get = function(info)
+							local t = E.db.sle.bags.artifactPower[info[#info]]
+							return t.r, t.g, t.b, t.a
+						end,
+						set = function(info, r, g, b)
+							E.db.sle.bags.artifactPower[info[#info]] = {}
+							local t = E.db.sle.bags.artifactPower[info[#info]]
+							t.r, t.g, t.b = r, g, b
+							AP:bagUpdate()
+						end,
+					},
+					short = {
+						order = 3,
+						type = "toggle",
+						name = L["Short text"],
+					},
+					fonts = {
+						order = 5,
+						type = "group",
+						guiInline = true,
+						name = L["Fonts"],
+						get = function(info) return E.db.sle.bags.artifactPower.fonts[ info[#info] ] end,
+						set = function(info, value) E.db.sle.bags.artifactPower.fonts[ info[#info] ] = value; AP:bagUpdate() end,
+						args = {
+							font = {
+								type = "select", dialogControl = 'LSM30_Font',
+								order = 1,
+								name = L["Font"],
+								values = AceGUIWidgetLSMlists.font,
+							},
+							size = {
+								order = 2,
+								name = L["Font Size"],
+								type = "range",
+								min = 6, max = 48, step = 1,
+							},
+							outline = {
+								order = 3,
+								name = L["Font Outline"],
+								desc = L["Set the font outline."],
+								type = "select",
+								values = {
+									["NONE"] = L["None"],
+									["OUTLINE"] = 'OUTLINE',
+
+									["MONOCHROMEOUTLINE"] = 'MONOCROMEOUTLINE',
+									["THICKOUTLINE"] = 'THICKOUTLINE',
+								},
+							},
+						},
+					},
+				},
+			},
 		},
 	}
 end