Quantcast

Shadows. This closes #215

Darthpred [08-01-16 - 10:28]
Shadows. This closes #215
Filename
CHANGELOG.txt
ElvUI_SLE/defaults/private.lua
ElvUI_SLE/defaults/profile.lua
ElvUI_SLE/locales/english.lua
ElvUI_SLE/locales/russian.lua
ElvUI_SLE/modules/enhancedshdows.lua
ElvUI_SLE/modules/load_modules.xml
ElvUI_SLE/modules/vehicle.lua
ElvUI_SLE/options/enhancedshadows_c.lua
ElvUI_SLE/options/load_options.xml
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index ed2cf89..ac5b903 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,9 +1,10 @@
 v3.09
 Additions:
 - Added button size and button spacing on enhanced vehicle bar. It also can now be moved around (mover is in S&L Misc config group)
-- Added an options to show characters item level as equipped/average format. Also this giant number is way less giant.
-- Added an options for Armory to show character stats that Blizzard decided we don't need. Movement speed anyone? Script based on DejaCharacterStats addon by Dejablue
-- Added an option to change location panel width based on location name length
+- New options to show characters item level as equipped/average format. Also this giant number is way less giant.
+- New options for Armory to show character stats that Blizzard decided we don't need. Movement speed anyone? Script based on DejaCharacterStats addon by Dejablue
+- New option to change location panel width based on location name length
+- New options to create a shadow for a number of ElvUI unitframes and actionbars
 Fixes:
 - Fixed instance indicator not updating when difficulty is changed inside the instance
 - Fixed Affinitii's addons profile not actually applying (got exactly zero reports on that one, shows how much people actually wanted the thing)
diff --git a/ElvUI_SLE/defaults/private.lua b/ElvUI_SLE/defaults/private.lua
index a432443..5687c3e 100644
--- a/ElvUI_SLE/defaults/private.lua
+++ b/ElvUI_SLE/defaults/private.lua
@@ -85,6 +85,33 @@ V["sle"] = {
 	["module"] = {
 		["screensaver"] = false,
 		["blizzmove"] = true,
+		["shadows"] = {
+			["vehicle"] = false,
+			["player"] = false,
+			["target"] = false,
+			["targettarget"] = false,
+			["focus"] = false,
+			["focustarget"] = false,
+			["pet"] = false,
+			["pettarget"] = false,
+			["boss"] = false,
+			["arena"] = false,
+			["actionbars"] = {
+				["bar1"] = false,
+				["bar2"] = false,
+				["bar3"] = false,
+				["bar4"] = false,
+				["bar5"] = false,
+				["bar6"] = false,
+				["bar7"] = false,
+				["bar8"] = false,
+				["bar9"] = false,
+				["bar10"] = false,
+				["stancebar"] = false,
+				["microbar"] = false,
+				["petbar"] = false,
+			},
+		},
 	},

 	["unitframe"] = {
diff --git a/ElvUI_SLE/defaults/profile.lua b/ElvUI_SLE/defaults/profile.lua
index 2fd1326..ce61ce2 100644
--- a/ElvUI_SLE/defaults/profile.lua
+++ b/ElvUI_SLE/defaults/profile.lua
@@ -597,6 +597,12 @@ P["sle"] = {
 			["tipThrottle"] = 15,
 			["panelTemplate"] = "Transparent",
 		},
+	--Shadows
+	['shadows'] = {
+		['shadowcolor'] = { ['r'] = 0, ['g'] = 0, ['b'] = 0 },
+		['classcolor'] = false,
+		['size'] = 3,
+	},
 	--Skins
 	["skins"] = {
 		["objectiveTracker"] = {
diff --git a/ElvUI_SLE/locales/english.lua b/ElvUI_SLE/locales/english.lua
index 9d63b03..6f5429a 100644
--- a/ElvUI_SLE/locales/english.lua
+++ b/ElvUI_SLE/locales/english.lua
@@ -402,6 +402,10 @@ L["Are you sure you want to remove |cff1784d1%s|r from currency datatexts?"] = t
 L["Hide panel background"] = true
 L["Don't show this panel, only datatexts assinged to it"] = true

+--Enhnced Shadows
+L["Enhanced Shadows"] = true
+L["Use shadows on..."] = true
+
 --Equip Manager
 L["Equipment Manager"] = true
 L["EM_DESC"] = "This module provides different options to automatically change your equipment sets on spec change or entering certain locations. All options are character based."
diff --git a/ElvUI_SLE/locales/russian.lua b/ElvUI_SLE/locales/russian.lua
index 15a503f..fabb02f 100644
--- a/ElvUI_SLE/locales/russian.lua
+++ b/ElvUI_SLE/locales/russian.lua
@@ -399,6 +399,10 @@ L["Account Time Played"] = "Время в игре на аккаунте"
 L["Hide panel background"] = "Скрыть фон"
 L["Don't show this panel, only datatexts assinged to it"] = "Не показывать фон панели, а только назначенные инфо-тексты."

+--Enhnced Shadows
+L["Enhanced Shadows"] = "Улучшенные тени"
+L["Use shadows on..."] = "Использовать тени на..."
+
 --Equip Manager
 L["Equipment Manager"] = "Менеджер экипировки"
 L["EM_DESC"] = "Этот модуль предоставляет различные опции для автоматической смены комплектов экипировки при переключении набора талантов или попадании в определенную локацию."
diff --git a/ElvUI_SLE/modules/enhancedshdows.lua b/ElvUI_SLE/modules/enhancedshdows.lua
new file mode 100644
index 0000000..c17e7b0
--- /dev/null
+++ b/ElvUI_SLE/modules/enhancedshdows.lua
@@ -0,0 +1,137 @@
+local SLE, T, E, L, V, P, G = unpack(select(2, ...))
+local ES = SLE:NewModule('EnhancedShadows', 'AceEvent-3.0')
+local AB, UF = SLE:GetElvModules("ActionBars", "UnitFrames")
+local ClassColor = RAID_CLASS_COLORS[E.myclass]
+local Border, LastSize
+local Abars = SLE._Compatibility["ElvUI_ExtraActionBars"] and 10 or 6
+--GLOBALS: hooksecurefunc
+local _G = _G
+local UnitAffectingCombat = UnitAffectingCombat
+
+ES.shadows = {}
+
+local UFrames = {
+	{"player", "Player"},
+	{"target", "Target"},
+	{"targettarget", "TargetTarget"},
+	{"focus", "Focus"},
+	{"focustarget", "FocusTarget"},
+	{"pet", "Pet"},
+	{"pettarget", "PetTarget"},
+}
+
+local UGroups = {
+	{"boss", "Boss", 5}
+	{"arena", "Arena", 5}
+}
+
+function ES:UpdateShadows()
+	if UnitAffectingCombat('player') then ES:RegisterEvent('PLAYER_REGEN_ENABLED', ES.UpdateShadows) return end
+
+	for frame, _ in T.pairs(ES.shadows) do
+		ES:UpdateShadow(frame)
+	end
+end
+
+function ES:RegisterShadow(shadow)
+	if shadow.isRegistered then return end
+	ES.shadows[shadow] = true
+	shadow.isRegistered = true
+end
+
+function ES:UpdateFrame(frame, db)
+	if not frame or not frame.EnhShadow then return end
+	local size = E.db.sle.shadows.size
+	if frame.USE_MINI_POWERBAR then
+		frame.EnhShadow:SetOutside(frame.Health, size, size)
+	else
+		frame.EnhShadow:SetOutside(frame, size, size)
+	end
+end
+
+function ES:CreateShadows()
+	for i = 1, #UFrames do
+		local unit, name = T.unpack(UFrames[i])
+		if E.private.sle.module.shadows[unit] then
+			local frame = _G["ElvUF_"..name]
+			frame:CreateShadow()
+			frame.EnhShadow = frame.shadow
+			frame.shadow = nil
+			ES:RegisterShadow(frame.EnhShadow)
+			hooksecurefunc(UF, "Update_"..name.."Frame", ES.UpdateFrame)
+		end
+	end
+	for i = 1, #UGroups do
+		local unit, name, num = T.unpack(UGroups[i])
+		if E.private.sle.module.shadows[unit] then
+			for j = 1, num do
+				local frame = _G["ElvUF_"..name..j]
+				frame:CreateShadow()
+				frame.EnhShadow = frame.shadow
+				frame.shadow = nil
+				ES:RegisterShadow(frame.EnhShadow)
+				hooksecurefunc(UF, "Update_"..name.."Frames", ES.UpdateFrame)
+			end
+		end
+	end
+	for i=1, Abars do
+		if E.private.sle.module.shadows.actionbars["bar"..i] then
+			local frame = _G["ElvUI_Bar"..i]
+			frame:CreateShadow()
+			frame.EnhShadow = frame.shadow
+			frame.shadow = nil
+			ES:RegisterShadow(frame.EnhShadow)
+		end
+	end
+	if E.private.sle.module.shadows.actionbars.stancebar then
+		local frame = _G["ElvUI_StanceBar"]
+		frame:CreateShadow()
+		frame.EnhShadow = frame.shadow
+		frame.shadow = nil
+		ES:RegisterShadow(frame.EnhShadow)
+	end
+	if E.private.sle.module.shadows.actionbars.microbar then
+		local frame = _G["ElvUI_MicroBar"]
+		frame:CreateShadow()
+		frame.EnhShadow = frame.shadow
+		frame.shadow = nil
+		ES:RegisterShadow(frame.EnhShadow)
+	end
+	if E.private.sle.module.shadows.actionbars.petbar then
+		local frame = _G["ElvUI_BarPet"]
+		frame:CreateShadow()
+		frame.EnhShadow = frame.shadow
+		frame.shadow = nil
+		ES:RegisterShadow(frame.EnhShadow)
+	end
+end
+
+function ES:UpdateShadow(shadow)
+	local ShadowColor = E.db.sle.shadows.shadowcolor
+	local r, g, b = ShadowColor['r'], ShadowColor['g'], ShadowColor['b']
+	if E.db.sle.shadows.classcolor then r, g, b = ClassColor['r'], ClassColor['g'], ClassColor['b'] end
+
+	local size = E.db.sle.shadows.size
+	if size ~= LastSize then
+		shadow:SetOutside(shadow:GetParent(), size, size)
+		shadow:SetBackdrop({
+			edgeFile = Border, edgeSize = E:Scale(size > 3 and size or 3),
+			insets = {left = E:Scale(5), right = E:Scale(5), top = E:Scale(5), bottom = E:Scale(5)},
+		})
+		LastSize = size
+	end
+	shadow:SetBackdropColor(r, g, b, 0)
+	shadow:SetBackdropBorderColor(r, g, b, 0.9)
+end
+
+function ES:Initialize()
+	if not SLE.initialized then return end
+	Border = E.LSM:Fetch('border', 'ElvUI GlowBorder')
+	ES:CreateShadows()
+	ES:UpdateShadows()
+	function ES:ForUpdateAll()
+		ES:UpdateShadows()
+	end
+end
+
+SLE:RegisterModule(ES:GetName())
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/load_modules.xml b/ElvUI_SLE/modules/load_modules.xml
index f4af73d..e551a50 100644
--- a/ElvUI_SLE/modules/load_modules.xml
+++ b/ElvUI_SLE/modules/load_modules.xml
@@ -12,6 +12,7 @@
 	<Script file='datatexts.lua'/>
 	<Script file='elvConfig.lua'/>
 	<Script file='equipmanager.lua'/>
+	<Script file='enhancedshdows.lua'/>
 	<Script file='toolbars.lua'/>
 	<Script file='garrison.lua'/>
 	<Script file='lfr.lua'/>
diff --git a/ElvUI_SLE/modules/vehicle.lua b/ElvUI_SLE/modules/vehicle.lua
index f73d95d..aeca141 100644
--- a/ElvUI_SLE/modules/vehicle.lua
+++ b/ElvUI_SLE/modules/vehicle.lua
@@ -2,6 +2,7 @@ local SLE, T, E, L, V, P, G = unpack(select(2, ...))
 local EVB = SLE:NewModule("EnhancedVehicleBar")
 local AB = E:GetModule("ActionBars");
 local LAB = LibStub("LibActionButton-1.0-ElvUI")
+local ES = SLE:GetModule("EnhancedShadows")
 --GLOBALS: CreateFrame, hooksecurefunc, UIParent
 local _G = _G
 local RegisterStateDriver = RegisterStateDriver
@@ -131,8 +132,8 @@ function EVB:Initialize()

 	bar:SetTemplate("Transparent");
 	bar:CreateShadow();
-	if (E:GetModule("EnhancedShadows", true)) then
-		E:GetModule("EnhancedShadows"):RegisterShadow(bar.shadow);
+	if E.private.sle.module.shadows.vehicle then
+		ES:RegisterShadow(bar.shadow);
 	end

 	bar:SetPoint("BOTTOM", 0, 34);
diff --git a/ElvUI_SLE/options/enhancedshadows_c.lua b/ElvUI_SLE/options/enhancedshadows_c.lua
new file mode 100644
index 0000000..ab58ff6
--- /dev/null
+++ b/ElvUI_SLE/options/enhancedshadows_c.lua
@@ -0,0 +1,144 @@
+local SLE, T, E, L, V, P, G = unpack(select(2, ...))
+local ES = SLE:GetModule("EnhancedShadows")
+
+local function configTable()
+	if not SLE.initialized then return end
+
+	E.Options.args.sle.args.modules.args.shadows = {
+		order = 5,
+		type = "group",
+		name = L["Enhanced Shadows"],
+		get = function(info) return E.db.sle.shadows[info[#info]] end,
+		set = function(info, value) E.db.sle.shadows[info[#info]] = value ES:UpdateShadows() end,
+		args = {
+			shadowcolor = {
+				type = "color",
+				order = 1,
+				name = L["Color"],
+				hasAlpha = false,
+				get = function(info)
+					local t = E.db.sle.shadows[info[#info]]
+					return t.r, t.g, t.b, t.a
+				end,
+				set = function(info, r, g, b)
+					E.db.sle.shadows[info[#info]] = {}
+					local t = E.db.sle.shadows[info[#info]]
+					t.r, t.g, t.b = r, g, b
+					ES:UpdateShadows()
+				end,
+			},
+			classcolor = {
+				type = 'toggle',
+				order = 2,
+				name = L["Use Class Color"],
+			},
+			size = {
+				order = 2,
+				type = 'range',
+				name = L["Size"],
+				min = 2, max = 10, step = 1,
+			},
+			frames = {
+				order = 4,
+				type = "group",
+				name = L["Use shadows on..."],
+				guiInline = true,
+				get = function(info) return E.private.sle.module.shadows[info[#info]] end,
+				set = function(info, value) E.private.sle.module.shadows[info[#info]] = value; E:StaticPopup_Show("PRIVATE_RL") end,
+				args = {
+					vehicle = {
+						order = 1,
+						type = "toggle",
+						name = L["Enhanced Vehicle Bar"],
+					},
+					unitframes = {
+						order = 2,
+						type = "group",
+						name = L["UnitFrames"],
+						args = {
+							player = {
+								order = 1,
+								type = "toggle",
+								name = L["Player Frame"],
+							},
+							target = {
+								order = 1,
+								type = "toggle",
+								name = L["Target Frame"],
+							},
+							targettarget = {
+								order = 1,
+								type = "toggle",
+								name = L["TargetTarget Frame"],
+							},
+							focus = {
+								order = 1,
+								type = "toggle",
+								name = L["Focus Frame"],
+							},
+							focustarget = {
+								order = 1,
+								type = "toggle",
+								name = L["FocusTarget Frame"],
+							},
+							pet = {
+								order = 1,
+								type = "toggle",
+								name = L["Pet Frame"],
+							},
+							pettarget = {
+								order = 1,
+								type = "toggle",
+								name = L["PetTarget Frame"],
+							},
+							boss = {
+								order = 1,
+								type = "toggle",
+								name = L["Boss Frames"],
+							},
+							arena = {
+								order = 1,
+								type = "toggle",
+								name = L["Arena Frames"],
+							},
+						},
+					},
+					actionbars = {
+						order = 10,
+						type = "group",
+						name = L["ActionBars"],
+						get = function(info) return E.private.sle.module.shadows.actionbars[info[#info]] end,
+						set = function(info, value) E.private.sle.module.shadows.actionbars[info[#info]] = value; E:StaticPopup_Show("PRIVATE_RL") end,
+						args = {
+							microbar = {
+								order = 1,
+								type = "toggle",
+								name = L["Micro Bar"],
+							},
+							stancebar = {
+								order = 2,
+								type = "toggle",
+								name = L["Stance Bar"],
+							},
+							petbar = {
+								order = 3,
+								type = "toggle",
+								name = L["Pet Bar"],
+							},
+						},
+					},
+				},
+			},
+		},
+	}
+
+	for i = 1, (SLE._Compatibility["ElvUI_ExtraActionBars"] and 10 or 6) do
+		E.Options.args.sle.args.modules.args.shadows.args.frames.args.actionbars.args["bar"..i] = {
+			order = i + 3,
+			type = "toggle",
+			name = L["Bar "]..i,
+		}
+	end
+end
+
+T.tinsert(SLE.Configs, configTable)
\ No newline at end of file
diff --git a/ElvUI_SLE/options/load_options.xml b/ElvUI_SLE/options/load_options.xml
index e3382f7..9ab22ca 100644
--- a/ElvUI_SLE/options/load_options.xml
+++ b/ElvUI_SLE/options/load_options.xml
@@ -19,6 +19,7 @@
 	<Script file='pvp_c.lua'/>
 	<Script file='backgrounds_c.lua'/>
 	<Script file='equipmanager_c.lua'/>
+	<Script file='enhancedshadows_c.lua'/>
 	<Script file='farm_c.lua'/>
 	<Script file='garrison_c.lua'/>
 	<Script file='loot_c.lua'/>